LoginSignup
5
5

More than 5 years have passed since last update.

Unity Android に DeployGate SDK を組み込む

Posted at

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

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/

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5