App - VirtueSky/sunflower GitHub Wiki
App is the struct helper reference to MonoGlobal
. It provides the following support methods
SubTick
,SubFixedTick
,SubLateTick
: Register to update onMonoGlobal
Example
private void Awake()
{
App.SubTick(CustomUpdate);
App.SubFixedTick(CustomFixedUpdate);
App.SubLateTick(CustomLateUpdate);
}
private void CustomUpdate()
{
Debug.Log("Update");
}
private void CustomFixedUpdate()
{
Debug.Log("Fixed Update");
}
private void CustomLateUpdate()
{
Debug.Log("Late Update");
}
UnSubTick
,UnSubFixedTick
,UnSubLateTick
: Cancel registration to perform updates on MonoGlobal
Example
private void OnDisable()
{
App.UnSubTick(CustomUpdate);
App.UnSubFixedTick(CustomFixedUpdate);
App.UnSubLateTick(CustomLateUpdate);
}
private void CustomUpdate()
{
Debug.Log("Update");
}
private void CustomFixedUpdate()
{
Debug.Log("Fixed Update");
}
private void CustomLateUpdate()
{
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
private void A()
{
App.Delay(1.5f, () => { Debug.Log("OnCompleted"); });
}
CancelDelay
:
Example
private void A()
{
var handleDelay = App.Delay(1.5f, () => { Debug.Log("OnCompleted"); });
App.CancelDelay(handleDelay);
}
PauseDelay
:
Example
private void A()
{
var handleDelay = App.Delay(1.5f, () => { Debug.Log("OnCompleted"); });
App.PauseDelay(handleDelay);
}
ResumeDelay
:
Example
private void A()
{
var handleDelay = App.Delay(1.5f, () => { Debug.Log("OnCompleted"); });
App.ResumeDelay(handleDelay);
}
CancelAllDelay
,PauseAllDelay
,ResumeAllDelay
:
Example
private void A()
{
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)
private void A()
{
App.Delay(this, 1.5f, () => { Debug.Log("OnCompleted"); }); // the target is `this`
}