示例#1
0
    void Awake()
    {
        if (Application.isPlaying)
        {
            gameObject.hideFlags = HideFlags.HideInHierarchy;
            DontDestroyOnLoad(gameObject);
        }

        // There can be only one!
        if (instance != null && instance != this)
        {
            GameObject.Destroy(instance);
            instance = this;
        }
    }
示例#2
0
    void OnDestroy()
    {
#if UNITY_EDITOR
        if (PlaymodeListener.IsQuitingPlaymode)
        {
            return;
        }
#endif

        // make sure we have somebody to continue our job if we get destroyed
        if (instance != this)
        {
            return;
        }
        instance = FindObjectOfType <InvokerProxyLate>();
        if (instance != null)
        {
            return;
        }
        instance = new GameObject("Invoker").AddComponent <InvokerProxyLate>();
    }
示例#3
0
 /// <summary>
 /// Assures there exists an instance of this type.
 /// </summary>
 public static void Touch()
 {
     if (instance != null)
     {
         return;
     }
     if (Thread.CurrentThread.ManagedThreadId != 1)
     {
         return;
     }
     if (!Application.isPlaying)
     {
         return;
     }
     instance = FindObjectOfType <InvokerProxyLate>();
     if (instance != null)
     {
         return;
     }
     instance = new GameObject("Invoker").AddComponent <InvokerProxyLate>();
 }