// 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); }
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); }
public static void RemoveTimer(FunctionPeriodic funcTimer) { funcList.Remove(funcTimer); }