- Notifications
You must be signed in to change notification settings - Fork 5
DucNV_2000 edited this page Jul 11, 2024
·
2 revisions
App is the struct helper reference to MonoGlobal. It provides the following support methods
SubTick,SubFixedTick,SubLateTick: Register to update onMonoGlobal
Example
privatevoidAwake(){App.SubTick(CustomUpdate);App.SubFixedTick(CustomFixedUpdate);App.SubLateTick(CustomLateUpdate);}privatevoidCustomUpdate(){Debug.Log("Update");}privatevoidCustomFixedUpdate(){Debug.Log("Fixed Update");}privatevoidCustomLateUpdate(){Debug.Log("Late Update");}UnSubTick,UnSubFixedTick,UnSubLateTick: Cancel registration to perform updates on MonoGlobal
Example
privatevoidOnDisable(){App.UnSubTick(CustomUpdate);App.UnSubFixedTick(CustomFixedUpdate);App.UnSubLateTick(CustomLateUpdate);}privatevoidCustomUpdate(){Debug.Log("Update");}privatevoidCustomFixedUpdate(){Debug.Log("Fixed Update");}privatevoidCustomLateUpdate(){Debug.Log("Late Update");}AddPauseCallback: insert callback inside OnApplicationPauseRemovePauseCallback:remove callback inside OnApplicationPause if it exitsAddFocusCallback: insert callback inside OnApplicationFocusRemoveFocusCallback: remove callback inside OnApplicationFocus if it exitsAddQuitCallback: insert callback inside OnApplicationQuitRemoveQuitCallback:remove callback inside OnApplicationQuit if it exitsStartCoroutine: start coroutine by MonoGlobalStopCoroutine: stop coroutine by MonoGlobalStopAllCoroutine: stop all coroutine by MonoGlobalToMainThread: Converts the specified action to one that runs on the main thread. The converted action will be invoked upon the next Unity Update event.RunOnMainThread: Schedules the specifies action to be run on the main thread (game thread). The action will be invoked upon the next Unity Update event.Delay: Handle delay
Example
privatevoidA(){App.Delay(1.5f,()=>{Debug.Log("OnCompleted");});}CancelDelay:
Example
privatevoidA(){varhandleDelay=App.Delay(1.5f,()=>{Debug.Log("OnCompleted");});App.CancelDelay(handleDelay);}PauseDelay:
Example
privatevoidA(){varhandleDelay=App.Delay(1.5f,()=>{Debug.Log("OnCompleted");});App.PauseDelay(handleDelay);}ResumeDelay:
Example
privatevoidA(){varhandleDelay=App.Delay(1.5f,()=>{Debug.Log("OnCompleted");});App.ResumeDelay(handleDelay);}CancelAllDelay,PauseAllDelay,ResumeAllDelay:
Example
privatevoidA(){App.CancelAllDelay();App.PauseAllDelay();App.ResumeAllDelay();}- Note: Safe Delay call when it had target, progress delay will be cancel when target was destroyed (The target is MonoBehaviour)
privatevoidA(){App.Delay(this,1.5f,()=>{Debug.Log("OnCompleted");});// the target is `this`}