Skip to content

Instantly share code, notes, and snippets.

@takashicompany
Created November 18, 2013 05:59
Show Gist options
  • Save takashicompany/7523219 to your computer and use it in GitHub Desktop.
Save takashicompany/7523219 to your computer and use it in GitHub Desktop.
UnityでAndroidプラグインの関数を使う時に使うスクリプト
void Awake () {
// UnityPlayerクラスを取得
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
// 現在のActivityを取得
AndroidJavaObject activity = jc.GetStatic<AndroidJavaObject>("currentActivity");
// Contextを取得
AndroidJavaObject context = activity.Call<AndroidJavaObject>("getApplicationContext");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment