Ejemplo n.º 1
0
 public static void Invoke(Action action, bool skipTouchingProxy = false)
 {
     if (action == null)
     {
         return;
     }
     invokeListBuffer.Add(action);
     if (skipTouchingProxy)
     {
         return;
     }
     InvokerProxy.Touch();
 }
Ejemplo n.º 2
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;
        }
    }
Ejemplo n.º 3
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 <InvokerProxy>();
        if (instance != null)
        {
            return;
        }
        instance = new GameObject("Invoker").AddComponent <InvokerProxy>();
    }
Ejemplo n.º 4
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 <InvokerProxy>();
     if (instance != null)
     {
         return;
     }
     instance = new GameObject("Invoker").AddComponent <InvokerProxy>();
 }