Class Timer
- Namespace
- UILib.Behaviours
- Assembly
- UILib.dll
Runs a timer.
public class Timer : MonoBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourTimer
- Derived
- Inherited Members
-
MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.Internal_CancelInvokeAll(MonoBehaviour)MonoBehaviour.Internal_IsInvokingAll(MonoBehaviour)MonoBehaviour.IsObjectMonoBehaviour(Object)MonoBehaviour.StopCoroutineManaged(Coroutine)MonoBehaviour.GetScriptClassName()MonoBehaviour.useGUILayoutBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.transformComponent.gameObjectComponent.tagObject.m_CachedPtrObject.OffsetOfInstanceIDInCPlusPlusObjectObject.objectIsNullMessageObject.cloneDestroyedMessageObject.GetInstanceID()Object.GetHashCode()Object.CompareBaseObjects(Object, Object)Object.EnsureRunningOnMainThread()Object.IsNativeObjectAlive(Object)Object.GetCachedPtr()Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectOfType<T>()Object.ToString()Object.GetOffsetOfInstanceIDInCPlusPlusObject()Object.CurrentThreadIsMainThread()Object.Internal_CloneSingle(Object)Object.Internal_InstantiateSingle(Object, Vector3, Quaternion)Object.Internal_InstantiateSingleWithParent(Object, Transform, Vector3, Quaternion)Object.ToString(Object)Object.GetName(Object)Object.IsPersistent(Object)Object.Internal_InstantiateSingle_Injected(Object, ref Vector3, ref Quaternion)Object.Internal_InstantiateSingleWithParent_Injected(Object, Transform, ref Vector3, ref Quaternion)Object.nameObject.hideFlags
Properties
onEnd
Invokes listeners when the timer finishes.
public UnityEvent onEnd { get; }
Property Value
- UnityEvent
onIter
Invokes listeners on each iteration of the timer. The value passed to listeners is the current value of the timer.
public ValueEvent<float> onIter { get; }
Property Value
onStart
Invokes listeners whenever the timer is started.
public UnityEvent onStart { get; }
Property Value
- UnityEvent
paused
Whether the timer should pause.
public bool paused { get; }
Property Value
running
Whether the timer coroutine is currently running.
public bool running { get; }
Property Value
timeScale
The time scale. By default this is 1.
Scales how quickly the timer should run.
The higher this value, the faster the timer runs. The lower this value, the slower the timer runs.
public float timeScale { get; }
Property Value
timer
The current value of the timer.
public float timer { get; }
Property Value
Methods
PauseTimer(bool)
Pauses the timer.
If the timer is paused, the internal timer will no longer
decrease, and any onIter listeners will no longer be invoked.
Passing false will allow the timer to continue
normal execution.
public void PauseTimer(bool pause = true)
Parameters
pauseboolWhether the timer should be paused
ReverseTimer()
Sets the timer to go in reverse of its current direction.
public void ReverseTimer()
SetTimeScale(float)
Sets the timeScale.
public void SetTimeScale(float timeScale)
Parameters
timeScalefloat
StartTimer(float, float)
Starts the timer. If the timer is already running, this will restart it.
Both the start and end time must be >= 0.
public void StartTimer(float startTime, float endTime = 0)
Parameters
StopTimer()
Stops the timer immediately.
public void StopTimer()