Ejemplo n.º 1
0
 private void OnDestroy()
 {
     if (current == this)
     {
         current = null;
     }
 }
Ejemplo n.º 2
0
        private void Awake()
        {
            if (current == null || current == this)
            {
                current = this;
            }
            else
            {
                Destroy(gameObject);
                return;
            }

            DontDestroyOnLoad(gameObject);
        }
Ejemplo n.º 3
0
        public static UnityThread CreateUnityThreadInstance(bool visible = true)
        {
            if (current != null)
            {
                return(current);
            }

            if (Application.isPlaying)
            {
                var obj = new GameObject("UnityThreadRunner");
                obj.hideFlags = visible ? HideFlags.HideAndDontSave : HideFlags.None;
                current       = obj.AddComponent <UnityThread>();
            }
            return(current);
        }