Class TimerExtensions | DOTS Timeline | 0.8.0-preview.1
docs.unity3d.com
    Show / Hide Table of Contents

    Class TimerExtensions

    Extension methods for Entity Manager that abstract the functionality of Timers

    Inheritance
    Object
    TimerExtensions
    Namespace: Unity.Scheduler
    Syntax
    public static class TimerExtensions

    Methods

    CreateTimer<T>(EntityManager, T)

    Given an entity, adds the appropriate components to create a functioning Timer

    Declaration
    public static Entity CreateTimer<T>(this EntityManager manager, T clockType = default(T))
        where T : struct, IClockComponent
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use

    T clockType

    The type of clock the entity should use to update with. This can be a compositeTimer

    Returns
    Type Description
    Entity
    Type Parameters
    Name Description
    T

    The type of clock the entity should use to update with

    GetTimerRange(EntityManager, Entity)

    Retrieve the current time interval the time operates in

    Declaration
    public static DiscreteTimeInterval GetTimerRange(this EntityManager manager, Entity e)
    Parameters
    Type Name Description
    EntityManager manager
    Entity e
    Returns
    Type Description
    DiscreteTimeInterval

    The range of time valid for this timer, or DiscreteTimeInterval.MaxRange if the timer does not have a range.

    GetTimerState(EntityManager, Entity)

    Returns the current state of the timer

    Declaration
    public static TimerState GetTimerState(this EntityManager manager, Entity e)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use

    Entity e

    The entity where the Timer lives

    Returns
    Type Description
    TimerState

    GetTimerStateFlags(EntityManager, Entity)

    Get the timers state flags. The state flags indicate events of significance that have occurred on the timer this frame, such as completed, looped, or seeked.

    Declaration
    public static TimerStateFlags GetTimerStateFlags(this EntityManager manager, Entity e)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use

    Entity e

    The entity where the Timer lives

    Returns
    Type Description
    TimerStateFlags

    GetTimerTime(EntityManager, Entity)

    Retrieves the current time of the timer.

    Declaration
    public static DiscreteTime GetTimerTime(this EntityManager manager, Entity e)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use

    Entity e

    The entity where the Timer lives

    Returns
    Type Description
    DiscreteTime

    The time the current timer is at.

    IsTimer(EntityManager, Entity)

    Returns whether the entity is a timer

    Declaration
    public static bool IsTimer(this EntityManager manager, Entity e)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use

    Entity e

    The entity where the Timer lives

    Returns
    Type Description
    Boolean

    True if the entity has the necessary components to be a timer, false otherwise

    IsTimerActive(EntityManager, Entity)

    Determine whether a timer is currently active.

    Declaration
    public static bool IsTimerActive(this EntityManager manager, Entity e)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use

    Entity e

    The entity where the Timer lives

    Returns
    Type Description
    Boolean

    PauseTimer(EntityManager, Entity)

    Pauses a timer.

    Pausing a timer will prevent the timer from advancing, but will allow items depending on the timer to update Pausing a playing timer will cause the timer to continue with 0 deltaTime. Pausing a paused timer will have no effect. Pausing a stopped timer will cause the timer to hold at it's current position.

    Declaration
    public static void PauseTimer(this EntityManager manager, Entity e)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use

    Entity e

    The entity where the Timer lives

    PlayTimer(EntityManager, Entity)

    Starts a timer playing. Playing a currently playing timer causes no change. Playing a paused or stopped timer causes the timer to start from it's current position

    Declaration
    public static void PlayTimer(this EntityManager manager, Entity e)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use

    Entity e

    The entity where the Timer lives

    SeekTimer(EntityManager, Entity, DiscreteTime)

    Seek Timer will set the next update time to a specific value

    On the next frame the timer will start playing at the given time (no delta time is added). The time is set regardless of the timer state.

    Declaration
    public static void SeekTimer(this EntityManager manager, Entity e, DiscreteTime time)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use

    Entity e

    The entity where the Timer lives

    DiscreteTime time

    The time to seek to

    SetTimerAutoPause(EntityManager, Entity, DiscreteTime, DiscreteTime)

    Sets a timer to automatically pause when it reaches the end of a given range

    Declaration
    public static void SetTimerAutoPause(this EntityManager manager, Entity e, DiscreteTime time0, DiscreteTime time1)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use.

    Entity e

    The entity where the Timer lives.

    DiscreteTime time0

    The minimum time value of the range.

    DiscreteTime time1

    The maximum time value of the range.

    SetTimerAutoStop(EntityManager, Entity, DiscreteTime, DiscreteTime, Boolean)

    Sets a timer to automatically stop when it reaches the end of a given range

    Declaration
    public static void SetTimerAutoStop(this EntityManager manager, Entity e, DiscreteTime time0, DiscreteTime time1, bool sampleLastFrame)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use.

    Entity e

    The entity where the Timer lives.

    DiscreteTime time0

    The minimum time value of the range.

    DiscreteTime time1

    The maximum time value of the range.

    Boolean sampleLastFrame

    Whether the timer should force the last frame to play before stopping.

    SetTimerLoop(EntityManager, Entity, DiscreteTime, DiscreteTime)

    Sets a timer to loop over a given range

    Declaration
    public static void SetTimerLoop(this EntityManager manager, Entity e, DiscreteTime time0, DiscreteTime time1)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use.

    Entity e

    The entity where the Timer lives.

    DiscreteTime time0

    The minimum time value of the range.

    DiscreteTime time1

    The maximum time value of the range.

    StopTimer(EntityManager, Entity)

    Stops a playing timer

    Stopping a timer does not reset the time, it stops the timer from advancing and disables it. Stopping a playing timer stops the timer. Stopping a paused timer stops the timer. Stopping a stopped timer has no effect.

    Declaration
    public static void StopTimer(this EntityManager manager, Entity e)
    Parameters
    Type Name Description
    EntityManager manager

    The entity manager to use

    Entity e

    The entity where the Timer lives

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023