1. Unity Tuning iOS method
In the homepage of the Viewcontroller inside the implementation method
void _pressbutton3 (const char *args)
{
Unityappcontroller *unityapp = (Unityappcontroller *) [uiapplication sharedapplication].delegate;
[Unityapp Showwindowssubview];
}
Call _pressbutton3 (content) directly inside unity;
2, iOS and Unity interaction, value
Unitysendmessage ("Scripts", [@ "Function" utf8string], [@ "Parameters" utf8string]);
3. Unity tune Android Inside the method
Add a method to the activity of initializing Unityplayer as follows:
/**
* Test Unity to call Android method
*/
public void TestMethod (String param) {
SYSTEM.OUT.PRINTLN ("parameter:" +param);
}
For the provided method, the UI operation is not possible because Unity3d for Android's UI thread, which is just a child thread, and you can use handler to send a message if you want to do a UI operation.
In Unity Engineering, use C # files to write the code that Unity calls:
public static void Activateshareimage (string content)
{
if (Application.platform = = Runtimeplatform.iphoneplayer)
{
_pressbutton3 (content);
}
else if (Application.platform = = runtimeplatform.android)
{
Uisystem.console ("Test method!");
Androidjavaclass JC = new Androidjavaclass ("Com.unity3d.player.UnityPlayer");
Androidjavaobject Jo = JC. Getstatic<androidjavaobject> ("currentactivity");
Jo. Call ("TestMethod", "unity");
}
Else
{
}
}
4. Android interacts with Unity
Unityplayer. Unitysendmessage ("Scripts", "Function", "Parameters");
Unity interacts with iOS, Android