Exemplo n.º 1
0
        // Persist through scene loads
        public static FunctionPeriodic Create_Global(Action action, Func <bool> testDestroy, float timer)
        {
            FunctionPeriodic functionPeriodic = Create(action, testDestroy, timer, "", false, false, false);

            MonoBehaviour.DontDestroyOnLoad(functionPeriodic.gameObject);
            return(functionPeriodic);
        }
Exemplo n.º 2
0
        public static FunctionPeriodic Create(Action action, Func <bool> testDestroy, float timer, string functionName, bool useUnscaledDeltaTime, bool triggerImmediately, bool stopAllWithSameName)
        {
            InitIfNeeded();

            if (stopAllWithSameName)
            {
                StopAllFunc(functionName);
            }

            GameObject       gameObject       = new GameObject("FunctionPeriodic Object " + functionName, typeof(MonoBehaviourHook));
            FunctionPeriodic functionPeriodic = new FunctionPeriodic(gameObject, action, timer, testDestroy, functionName, useUnscaledDeltaTime);

            gameObject.GetComponent <MonoBehaviourHook>().OnUpdate = functionPeriodic.Update;

            funcList.Add(functionPeriodic);

            if (triggerImmediately)
            {
                action();
            }

            return(functionPeriodic);
        }
Exemplo n.º 3
0
 public static void RemoveTimer(FunctionPeriodic funcTimer)
 {
     InitIfNeeded();
     funcList.Remove(funcTimer);
 }