Hi,
I want to know that how we can call Native Android Layouts from Unity3d. Let say i create Login form in Native Android app and now i want to call in Unity3d as popup window. So if any one knows then please share.
Any help will be appreciated.
Hi,
I want to know that how we can call Native Android Layouts from Unity3d. Let say i create Login form in Native Android app and now i want to call in Unity3d as popup window. So if any one knows then please share.
Any help will be appreciated.
For triggering Android native code from unity, you need to create a android plugin and call the methods from your unity scripts.
It won’t be tough to write a plugin in your case as its not of functionality.
Steps:
Create a library project for the Android native code and place the .jar file in Assets/Plugins/Android/YOUR_PROJECT_FOLDER/libs
In your library, create a class which interacts with unity and delivers the required actions (something like a bridge class for better workflow)
From unity , create an instance of AndroidJavaObject with the name of your bridge class.
//Create instance
AndroidJavaClass _class = new AndroidJavaClass(_className);
From the above instance, call the required methods.
Plugin.Call(AndroidNativeInfo.Methods.SHOW_POP_UP, _param1); //For instance method
AndroidJavaClass _class = new AndroidJavaClass(_className); //For Static calls
_class.CallStatic(AndroidNativeInfo.Methods.SHOW_POP_UP, _params…);
For getting back the results to unity, you need to use UnitySendMessage of UnityPlayer class provided by unity on Android native side.
//Passing message/data from Android Native to Unity
UnityPlayer.UnitySendMessage(UnityDefines.GAME_OBJECT_NAME, UnityDefines.METHOD_NAME, message);
Thats it & good luck
Adding to it, would like to suggest our free plugin Cross Platform Native Plugins which can be useful for accessing native popups like Alert Dialogs, Prompt Dialogs and many more useful features.
do you mean, you want to have native dialogs/alerts?
– Voxel-Busters