コード例 #1
0
    /*
     #if (ENABLE_LATEUPDATE_FUNCTION_CALLBACK)
     * public static void executeInLateUpdate(System.Action action)
     * {
     *  if (action == null)
     *  {
     *      throw new ArgumentNullException("action");
     *  }
     *
     *  lock (actionQueuesLateUpdateFunc)
     *  {
     *      actionQueuesLateUpdateFunc.Add(action);
     *      noActionQueueToExecuteLateUpdateFunc = false;
     *  }
     * }
     *
     * public void LateUpdate()
     * {
     *  if (noActionQueueToExecuteLateUpdateFunc)
     *  {
     *      return;
     *  }
     *
     *  //Clear the old actions from the actionCopiedQueueLateUpdateFunc queue
     *  actionCopiedQueueLateUpdateFunc.Clear();
     *  lock (actionQueuesLateUpdateFunc)
     *  {
     *      //Copy actionQueuesLateUpdateFunc to the actionCopiedQueueLateUpdateFunc variable
     *      actionCopiedQueueLateUpdateFunc.AddRange(actionQueuesLateUpdateFunc);
     *      //Now clear the actionQueuesLateUpdateFunc since we've done copying it
     *      actionQueuesLateUpdateFunc.Clear();
     *      noActionQueueToExecuteLateUpdateFunc = true;
     *  }
     *
     *  // Loop and execute the functions from the actionCopiedQueueLateUpdateFunc
     *  for (int i = 0; i < actionCopiedQueueLateUpdateFunc.Count; i++)
     *  {
     *      actionCopiedQueueLateUpdateFunc[i].Invoke();
     *  }
     * }
     #endif
     *
     * ////////////////////////////////////////////FIXEDUPDATE IMPL//////////////////////////////////////////////////
     #if (ENABLE_FIXEDUPDATE_FUNCTION_CALLBACK)
     * public static void executeInFixedUpdate(System.Action action)
     * {
     *  if (action == null)
     *  {
     *      throw new ArgumentNullException("action");
     *  }
     *
     *  lock (actionQueuesFixedUpdateFunc)
     *  {
     *      actionQueuesFixedUpdateFunc.Add(action);
     *      noActionQueueToExecuteFixedUpdateFunc = false;
     *  }
     * }
     *
     * public void FixedUpdate()
     * {
     *  if (noActionQueueToExecuteFixedUpdateFunc)
     *  {
     *      return;
     *  }
     *
     *  //Clear the old actions from the actionCopiedQueueFixedUpdateFunc queue
     *  actionCopiedQueueFixedUpdateFunc.Clear();
     *  lock (actionQueuesFixedUpdateFunc)
     *  {
     *      //Copy actionQueuesFixedUpdateFunc to the actionCopiedQueueFixedUpdateFunc variable
     *      actionCopiedQueueFixedUpdateFunc.AddRange(actionQueuesFixedUpdateFunc);
     *      //Now clear the actionQueuesFixedUpdateFunc since we've done copying it
     *      actionQueuesFixedUpdateFunc.Clear();
     *      noActionQueueToExecuteFixedUpdateFunc = true;
     *  }
     *
     *  // Loop and execute the functions from the actionCopiedQueueFixedUpdateFunc
     *  for (int i = 0; i < actionCopiedQueueFixedUpdateFunc.Count; i++)
     *  {
     *      actionCopiedQueueFixedUpdateFunc[i].Invoke();
     *  }
     * }
     #endif
     */

    public void OnDestroy()
    {
        if (instance == this)
        {
            instance = null;
        }
    }
コード例 #2
0
 public void Awake()
 {
     Debug.Assert(instance == null);
     instance = this;
     DontDestroyOnLoad(gameObject);
 }