Unity调用Android
1.Unity调用Android 根据unity用户手册,unity可以采用native code(c/c++),但是也提供了C#调用方法,本文对此进行简单讲解。 2.Unity获取android类 通过下述方法即可获取包com.ii.intentreceiver(可类比于C#命名空间)下的类MainActivity。继而可以调用MainActivity的静态方法getIntentResult。其返回值为string,如果无返回值,则直接调用CallStatic即可。 using (AndroidJavaClass mainActivityClass = new AndroidJavaClass("com.ii.intentreceiver.MainActivity")) { Debug.Log("IntentReceiver start catch infomation"); try { result = mainActivityClass.CallStatic<string>("getIntentResult"); } catch(Exception ex) { Debug.Log("IntentReceiver get result failed:" + ex.Message); } } 3.Unity获取android类的实例 通过下述方法即可获取包com.ii