Hi,
I have an error when I called this methods :
package com.baringsprod.naandroidunity;
import com.unity3d.player.UnityPlayerActivity;
public class UnityBridge extends UnityPlayerActivity
{
public static final String STATS_NAME = “NaStats”;
public static final String STATS_MAXLEVEL_TOK = “NaStatsMaxLevel”;
public enum NaGameType
{
kEasy,
kMedium,
kExpert
}
private int getMaxLevelForType_( NaGameType type )
{
return getSharedPreferences(STATS_NAME, 0).getInt(STATS_MAXLEVEL_TOK + type, 0);
}
public int getMaxLevelEasy()
{
return getMaxLevelForType_( NaGameType.kEasy );
}
public int getMaxLevelMedium()
{
return getMaxLevelForType_( NaGameType.kMedium );
}
public int getMaxLevelExpert()
{
return getMaxLevelForType_( NaGameType.kExpert );
}
I call them with this C# script :
// Get Android context
AndroidJavaClass unityPlayer = new AndroidJavaClass(“com.unity3d.player.UnityPlayerActivity”);
AndroidJavaObject activity = unityPlayer.GetStatic(“currentActivity”);
AndroidJavaObject app = activity.Call(“getApplicationContext”);
// Install DeployGate, make sure it will not called twice in your app
deployGate = new AndroidJavaClass(“com.baringsprod.naandroidunity.UnityBridge”);
activity.Call(“runOnUiThread”, new AndroidJavaRunnable(() =>
{
recupDiff0 = deployGate.CallStatic(“getMaxLevelEasy”, app);
recupDiff1 = deployGate.CallStatic(“getMaxLevelMedium”, app);
recupDiff2 = deployGate.CallStatic(“getMaxLevelExpert”, app);
NAUtil.UnlockLevelForDifficulty(recupDiff0,0);
NAUtil.UnlockLevelForDifficulty(recupDiff1,1);
NAUtil.UnlockLevelForDifficulty(recupDiff2,2);
Debug.Log("!!! GetPreferenceString success - level returned = " + recupDiff0 + " / " + recupDiff1 + " / " + recupDiff2);
}));
What am I doing wrong ?
Thanks for the help !