Struct SystemState | Entities | 0.16.0-preview.21
docs.unity3d.com
    Show / Hide Table of Contents

    Struct SystemState

    Contains raw entity system state. Used by unmanaged systems (ISystemBase) as well as managed systems behind the scenes.

    Namespace: Unity.Entities
    Syntax
    public struct SystemState

    Properties

    DebugName

    Return a debug name for unmanaged systems.

    Declaration
    public FixedString64 DebugName { get; }
    Property Value
    Type Description
    FixedString64

    Dependency

    The ECS-related data dependencies of the system.

    Declaration
    public JobHandle Dependency { get; set; }
    Property Value
    Type Description
    JobHandle
    Remarks

    Before , the Dependency property represents the combined job handles of any job that writes to the same components that the current system reads -- or reads the same components that the current system writes to. When you use Entities.ForEach or Job.WithCode, the system uses the Dependency property to specify a job’s dependencies when scheduling it. The system also combines the new job's JobHandle with Dependency so that any subsequent job scheduled in the system depends on the earlier jobs (in sequence).

    You can opt out of this default dependency management by explicitly passing a JobHandle to Entities.ForEach or Job.WithCode. When you pass in a JobHandle, these constructions also return a JobHandle representing the input dependencies combined with the new job. The JobHandle objects of any jobs scheduled with explicit dependencies are not combined with the system’s Dependency property. You must set the Dependency property manually to make sure that later systems receive the correct job dependencies.

    You can combine implicit and explicit dependency management (by using JobHandle.CombineDependencies); however, doing so can be error prone. When you set the Dependency property, the assigned JobHandle replaces any existing dependency, it is not combined with them.

    Note that the default, implicit dependency management does not include IJobChunk jobs. You must manage the dependencies for IJobChunk explicitly.

    Enabled

    Controls whether this system executes when its OnUpdate function is called.

    Declaration
    public bool Enabled { get; set; }
    Property Value
    Type Description
    Boolean

    True, if the system is enabled.

    Remarks

    The Enabled property is intended for debugging so that you can easily turn on and off systems from the Entity Debugger window. A system with Enabled set to false will not update, even if its Unity.Entities.SystemState.ShouldRunSystem function returns true.

    EntityManager

    The EntityManager object of the World in which this system exists.

    Declaration
    public EntityManager EntityManager { get; }
    Property Value
    Type Description
    EntityManager

    The EntityManager for this system.

    GlobalSystemVersion

    The current change version number in this World.

    Declaration
    public uint GlobalSystemVersion { get; }
    Property Value
    Type Description
    UInt32
    Remarks

    The system updates the component version numbers inside any ArchetypeChunk instances that this system accesses with write permissions to this value.

    LastSystemVersion

    The current version of this system.

    Declaration
    public uint LastSystemVersion { get; }
    Property Value
    Type Description
    UInt32

    The GlobalSystemVersion the last time this system ran.

    Remarks

    LastSystemVersion is updated to match the GlobalSystemVersion whenever a system runs.

    When you use SetChangedVersionFilter(ComponentType) or DidChange(DynamicComponentTypeHandle, UInt32), LastSystemVersion provides the basis for determining whether a component could have changed since the last time the system ran.

    When a system accesses a component and has write permission, it updates the change version of that component type to the current value of LastSystemVersion. The system updates the component type's version whether or not it actually modifies data in any instances of the component type -- this is one reason why you should specify read-only access to components whenever possible.

    For efficiency, ECS tracks the change version of component types by chunks, not by individual entities. If a system updates the component of a given type for any entity in a chunk, then ECS assumes that the components of all entities in that chunk could have been changed. Change filtering allows you to save processing time by skipping all entities in an unchanged chunk, but does not support skipping individual entities in a chunk that does contain changes.

    Time

    The current Time data for this system's world.

    Declaration
    public TimeData Time { get; }
    Property Value
    Type Description
    TimeData

    UnmanagedMetaIndex

    Return the unmanaged type index of the system (>= 0 for ISystemBase-type systems), or -1 for managed systems.

    Declaration
    public int UnmanagedMetaIndex { get; }
    Property Value
    Type Description
    Int32

    World

    The World in which this system exists.

    Declaration
    public World World { get; }
    Property Value
    Type Description
    World

    The World of this system.

    WorldUnmanaged

    The unmanaged portion of the world in which this system exists.

    Declaration
    public WorldUnmanaged WorldUnmanaged { get; }
    Property Value
    Type Description
    WorldUnmanaged

    The unmanaged world of this system.

    Methods

    CompleteDependency()

    Declaration
    public void CompleteDependency()

    GetBufferTypeHandle<T>(Boolean)

    Gets the run-time type information required to access an array of buffer components in a chunk.

    Declaration
    public BufferTypeHandle<T> GetBufferTypeHandle<T>(bool isReadOnly = false)
        where T : struct, IBufferElementData
    Parameters
    Type Name Description
    Boolean isReadOnly

    Whether the data is only read, not written. Access data as read-only whenever possible.

    Returns
    Type Description
    BufferTypeHandle<T>

    An object representing the type information required to safely access buffer components stored in a chunk.

    Type Parameters
    Name Description
    T

    A struct that implements IBufferElementData.

    Remarks

    Pass a BufferTypeHandle instance to a job that has access to chunk data, such as an IJobChunk job, to access that type of buffer component inside the job.

    GetComponentTypeHandle<T>(Boolean)

    Gets the run-time type information required to access an array of component data in a chunk.

    Declaration
    public ComponentTypeHandle<T> GetComponentTypeHandle<T>(bool isReadOnly = false)
        where T : struct, IComponentData
    Parameters
    Type Name Description
    Boolean isReadOnly

    Whether the component data is only read, not written. Access components as read-only whenever possible.

    Returns
    Type Description
    ComponentTypeHandle<T>

    An object representing the type information required to safely access component data stored in a chunk.

    Type Parameters
    Name Description
    T

    A struct that implements IComponentData.

    Remarks

    Pass an ComponentTypeHandle<T> instance to a job that has access to chunk data, such as an IJobChunk job, to access that type of component inside the job.

    GetDynamicComponentTypeHandle(ComponentType)

    Gets the run-time type information required to access an array of component data in a chunk.

    Declaration
    public DynamicComponentTypeHandle GetDynamicComponentTypeHandle(ComponentType componentType)
    Parameters
    Type Name Description
    ComponentType componentType

    Type of the component

    Returns
    Type Description
    DynamicComponentTypeHandle

    An object representing the type information required to safely access component data stored in a chunk.

    Remarks

    Pass an DynamicComponentTypeHandle instance to a job that has access to chunk data, such as an IJobChunk job, to access that type of component inside the job.

    GetEntityQuery(NativeArray<ComponentType>)

    Gets the cached query for the specified component types, if one exists; otherwise, creates a new query instance and caches it.

    Declaration
    public EntityQuery GetEntityQuery(NativeArray<ComponentType> componentTypes)
    Parameters
    Type Name Description
    NativeArray<ComponentType> componentTypes

    An array of component types.

    Returns
    Type Description
    EntityQuery

    The new or cached query.

    GetEntityQuery(ComponentType[])

    Gets the cached query for the specified component types, if one exists; otherwise, creates a new query instance and caches it.

    Declaration
    public EntityQuery GetEntityQuery(params ComponentType[] componentTypes)
    Parameters
    Type Name Description
    ComponentType[] componentTypes

    An array or comma-separated list of component types.

    Returns
    Type Description
    EntityQuery

    The new or cached query.

    GetEntityQuery(EntityQueryDesc[])

    Combines an array of query description objects into a single query.

    Declaration
    public EntityQuery GetEntityQuery(params EntityQueryDesc[] queryDesc)
    Parameters
    Type Name Description
    EntityQueryDesc[] queryDesc

    An array of query description objects to be combined to define the query.

    Returns
    Type Description
    EntityQuery

    The new or cached query.

    Remarks

    This function looks for a cached query matching the combined query descriptions, and returns it if one exists; otherwise, the function creates a new query instance and caches it.

    GetEntityTypeHandle()

    Gets the run-time type information required to access the array of Entity objects in a chunk.

    Declaration
    public EntityTypeHandle GetEntityTypeHandle()
    Returns
    Type Description
    EntityTypeHandle

    An object representing the type information required to safely access Entity instances stored in a chunk.

    GetSharedComponentTypeHandle<T>()

    Gets the run-time type information required to access a shared component data in a chunk.

    Declaration
    public SharedComponentTypeHandle<T> GetSharedComponentTypeHandle<T>()
        where T : struct, ISharedComponentData
    Returns
    Type Description
    SharedComponentTypeHandle<T>

    An object representing the type information required to safely access shared component data stored in a chunk.

    Type Parameters
    Name Description
    T

    A struct that implements ISharedComponentData.

    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