-
Notifications
You must be signed in to change notification settings - Fork 17
App
Struct helper reference to GlobalComponent
. It provides the following support methods
-
DeltaTime
: Get deltatime or unscaleDeltaTime based on the passed parametersETimeMode
-
AddListener
: Insert action in specifiedUpdateMode
,UpdateMode
is an enum that includes :- Update
- FixedUpdate
- LateUpdate
Example: Call method CalculatePower
inside Update
App.AddListener(UpdateMode.Update, CalculatePower);
-
RemoveListener
: Remove action in specifiedUpdateMode
Example: remove methodCalculatePower
insideUpdate
if it exists
App.RemoveListener(UpdateMode.Update, CalculatePower);
-
AddPauseCallback
: insert callback inside OnApplicationPause -
RemovePauseCallback
: remove callback inside OnApplicationPause if it exits -
AddQuitCallback
: insert callback inside OnApplicationQuit -
RemoveQuitCallback
: remove callback inside OnApplicationQuit if it exits -
AddFocusCallback
: insert callback inside OnApplicationFocus -
RemoveFocusCallback
: remove callback inside OnApplicationFocus if it exits -
StartCoroutine
: start coroutine by GlobalComponent -
StopCoroutine
: stop coroutine by GlobalComponent -
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
: delay call action, you can insert onUpdate during delay
App.Delay(2, MoveRight); // Method MoveRight called after 2 seconds
-
CancelDelay
: cancel delay process if it still incompleted
var handle = App.Delay(2, MoveRight);
App.CancelDelay(handle); // Cancel delay
-
PauseDelay
: Pause delay process
var handle = App.Delay(2, MoveRight);
App.PauseDelay(handle); // Pause delay
-
ResumeDelay
: Resume pause delay process
var handle = App.Delay(2, MoveRight);
App.PauseDelay(handle);
App.ResumeDelay(handle); // Resume delay
If you want to pause all , cancel all or resume full delay you can use CancelAllDelay
, PauseAllDelay
, ResumeAllDelay
-
StopAndClean(ref AsyncProcessHandle handle)
: Stop coroutine and assign null for handle
private AsyncProcessHandle _handle;
...
private IEnumerator IeAim()
{
// TODO
}
...
_handle = App.StartCoroutine(IeAim());
...
App.StopAndClean(ref _handle); // this is it
-
StopAndReassign
: Stop coroutine and assign a new routine for handle
private IEnumerator IeShoot()
{
// TODO
}
App.StopAndClean(ref _handle, IeShoot);
-
StopAndClean(ref DelayHandle handle)
: Stop Delay and assign null for handle
private DelayHandle _handle;
...
_handle = App.Delay(1f, ()=>{});
...
App.StopAndClean(ref _handle); // This is it