Last active
August 29, 2015 14:05
-
-
Save WestHillApps/2ef83b5f7ce9f0ef705d to your computer and use it in GitHub Desktop.
AndroidのUIスレッドで動作させる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class RunOnUiThreadExample : MonoBehaviour | |
{ | |
void Start () | |
{ | |
#if UNITY_ANDROID | |
AndroidJavaClass unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"); | |
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject> ("currentActivity"); | |
activity.Call ("runOnUiThread", new AndroidJavaRunnable (RunOnUiThread)); | |
#endif | |
} | |
void RunOnUiThread () | |
{ | |
Debug.Log ("I'm running on the Java UI thread!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment