Skip to content

Instantly share code, notes, and snippets.

@WestHillApps
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WestHillApps/2ef83b5f7ce9f0ef705d to your computer and use it in GitHub Desktop.
Save WestHillApps/2ef83b5f7ce9f0ef705d to your computer and use it in GitHub Desktop.
AndroidのUIスレッドで動作させる
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