Class BaseTimer
- Namespace
- UILib.Behaviours
- Assembly
- UILib.dll
A reversible timer which always goes between 0 and a set duration.
public abstract class BaseTimer : MonoBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourBaseTimer
- 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
duration
The total length of time this timer will take to run.
public float duration { get; }
Property Value
increasing
Whether this timer is increasing or decreasing.
Increasing means the timer is heading towards
the duration.
Decreasing means the timer is heading towards 0.
protected bool increasing { get; }
Property Value
running
Whether the timer is currently running.
public bool running { get; }
Property Value
time
The current time this timer is at.
public float time { get; }
Property Value
timeScale
This timer's current time scale.
This determines how quickly the timer runs by scaling the time delta on each iteration by this value.
A higher time scale means a faster timer, a lower time scale means a slower timer.
protected float timeScale { get; }
Property Value
Methods
ForceRun()
Forces the timer to reach an end point.
If the timer is set to be increasing, the end point will
be the duration.
If the timer is set to be decreasing, the end point will be 0.
public virtual void ForceRun()
OnEnd()
Runs when the timer reaches an end point.
This would be duration if the timer is increasing,
and 0 if decreasing.
protected virtual void OnEnd()
OnIter(float)
Runs on each iteration of the timer.
protected virtual void OnIter(float time)
Parameters
timefloatThe current value of the timer
OnStart()
Runs just before the timer's coroutine starts running.
protected virtual void OnStart()
RestartTimer()
Restarts the timer.
If the timer is set to be increasing, the timer
will start from 0.
Otherwise, the timer will start from duration.
public virtual void RestartTimer()
Reverse()
Tells the timer to go in the reverse of its current direction.
public virtual void Reverse()
SetDuration(float)
Sets how long this timer should take to run.
public virtual void SetDuration(float duration)
Parameters
durationfloatThe duration to set
SetIncreasing(bool)
Sets the direction this timer should run in.
public virtual void SetIncreasing(bool increasing)
Parameters
increasingboolWhether this timer should be increasing
SetTime(float)
protected virtual void SetTime(float time)
Parameters
timefloatThe value to set the time to
SetTimeScale(float)
Sets the timer's timeScale.
This determines how quickly the timer will run.
This value must be >= 0.
public virtual void SetTimeScale(float timeScale)
Parameters
timeScalefloatThe time scale to set
SetToEnd()
public void SetToEnd()
SetToStart()
Sets the time to 0.
public void SetToStart()
StartTimer()
Starts the timer.
The timer will continue running from its current time. If the timer routine is already running, this method does nothing.
public virtual void StartTimer()
StopTimer()
Stops the timer immediately.
This stops the coroutine, but keeps the time at its current value.
Note: This doesn't run OnEnd().
public virtual void StopTimer()