sorry bad english made android plugin unity3d v4.5 command prompt, jdk, sdk , apache ant. command "ant jar" built no errors, when try open game in mobile device, tells me: "unfortunately, thegame has stopped." mobile android 4.1.2 (api 16) , built game in api 15.
before using plugin had no problems , had no errors using apache , jdk.
this java code "mylibrary.java" in src\com\test\app:
package com.test.app; import com.unity3d.player.unityplayeractivity; public class mylibrary extends unityplayeractivity { public static float getvalue() { return 1.0f; } }
as see, want use float number (1.0f)
this manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.app" android:versioncode="1" android:versionname="1.0"> <supports-screens android:smallscreens="true" android:normalscreens="true" android:largescreens="true" android:xlargescreens="true" android:anydensity="true"/> <application android:label="@string/app_name" android:icon="@drawable/app_icon"> <activity android:name=".mylibrary" android:label="@string/app_name" android:configchanges="fontscale|keyboard|keyboardhidden|locale|mnc|mcc|navigation|orientation|screenlayout|screensize|smallestscreensize|uimode|touchscreen"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name="com.unity3d.player.unityplayeractivity" android:label="@string/app_name" android:configchanges="fontscale|keyboard|keyboardhidden|locale|mnc|mcc|navigation|orientation|screenlayout|screensize|smallestscreensize|uimode|touchscreen"> </activity> </application> </manifest>
and it`s c# script unity:
using unityengine; using system.collections; public class test : monobehaviour { androidjavaclass plugintutorialactivityjavaclass; public string getvalue () { androidjni.attachcurrentthread(); plugintutorialactivityjavaclass = new androidjavaclass("com.test.app.mylibrary"); float number = plugintutorialactivityjavaclass.callstatic<float>("getvalue"); return number.tostring(); } string val = ""; void ongui() { if(gui.button(new rect(0,0,200,200),"getvalue")) { val = getvalue(); } gui.textarea(new rect(0,200,200,200),val); } }
did wrong? me please thanks
Comments
Post a Comment