Skip to main content

Posts

Showing posts from October, 2013

Unity Plugin (Android)

I've been working on creating a plugin for unity(Android). The latest versions of unity (4.x) provide clean way of accessing the java side of things on android. If you want access to the android activity from android,  all you have to do is call the following.. AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = unityPlayer.GetStatic ("currentActivity"); This doesn't give us much of a head way... i.e, if you want to add any functionality you will have to extend the UnityPlayerActivity and add the functions you want and call them. But there is a more elegant way of doing it. You can just create a jar file from your android library and access its' functionality like so.. AndroidJavaClass   _pluginClass = new AndroidJavaClass ( "com.vkgamedev.MyTestLib.MyTestLib" ); _pluginClass.CallStatic( "setGoogleProjectId" , googleProjectId); If your  libr