Android
Unity
DeployGate

Unity Android に DeployGate SDK を組み込む

More than 3 years have passed since last update.

以下のようなクラスを作成


DeployGateAndroid.cs

using System.Collections;

public class DeployGateAndroid {
#if UNITY_ANDROID && !UNITY_EDITOR
private static AndroidJavaClass deployGate = null;

public static void Install() {
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject app = activity.Call<AndroidJavaObject>("getApplicationContext");
deployGate = new AndroidJavaClass ("com.deploygate.sdk.DeployGate");
activity.Call("runOnUiThread",new AndroidJavaRunnable(() =>{
deployGate.CallStatic ("install", app, null, true);
}));
}
#endif
}


ゲームの起動時に実行される処理の中で Install() を呼びだす。


main.cs

#if UNITY_ANDROID && !UNITY_EDITOR

// DeployGate SDK for Android のインストール
DeployGateAndroid.Install();
#endif


参考

[Deploygate-with-unity]UnityでDeployGateを使うためのアセット

http://anchan828.github.io/deploygate-with-unity/