コード例 #1
0
ファイル: UnityThread.cs プロジェクト: Corbyncc/tttunturned
 public void OnDisable()
 {
     if (instance == this)
     {
         instance = null;
     }
 }
コード例 #2
0
ファイル: UnityThread.cs プロジェクト: Corbyncc/tttunturned
        // Used to know if whe have new Action function to execute. This prevents the use of the lock keyword every frame
        //private volatile static bool noActionQueueToExecuteFixedUpdateFunc = true;


        //Used to initialize UnityThread. Call once before any function here
        public static void initUnityThread(bool visible = false)
        {
            if (instance != null)
            {
                return;
            }

            if (Application.isPlaying)
            {
                // add an invisible game object to the scene
                GameObject obj = new GameObject("MainThreadExecuter");
                if (!visible)
                {
                    obj.hideFlags = HideFlags.HideAndDontSave;
                }

                DontDestroyOnLoad(obj);
                instance = obj.AddComponent <UnityThread>();
            }
        }