Skip to content
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 on MonoGlobal

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 OnApplicationPause
  • RemovePauseCallback:remove callback inside OnApplicationPause if it exits
  • AddFocusCallback: insert callback inside OnApplicationFocus
  • RemoveFocusCallback: remove callback inside OnApplicationFocus if it exits
  • AddQuitCallback: insert callback inside OnApplicationQuit
  • RemoveQuitCallback:remove callback inside OnApplicationQuit if it exits
  • StartCoroutine: start coroutine by MonoGlobal
  • StopCoroutine: stop coroutine by MonoGlobal
  • StopAllCoroutine: stop all coroutine by MonoGlobal
  • ToMainThread: 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`}

Clone this wiki locally