Class ComponentSystem | Entities | 0.11.2-preview.1
docs.unity.cn
    Show / Hide Table of Contents

    Class ComponentSystem

    An abstract class to implement in order to create a system.

    Inheritance
    Object
    ComponentSystemBase
    ComponentSystem
    GameObjectConversionSystem
    ComponentSystemGroup
    ConvertToEntitySystem
    EntityCommandBufferSystem
    UpdateWorldTimeSystem
    SceneSystem
    Inherited Members
    ComponentSystemBase.Enabled
    ComponentSystemBase.EntityQueries
    ComponentSystemBase.GlobalSystemVersion
    ComponentSystemBase.LastSystemVersion
    ComponentSystemBase.EntityManager
    ComponentSystemBase.World
    ComponentSystemBase.Time
    ComponentSystemBase.OnCreateForCompiler()
    ComponentSystemBase.OnCreate()
    ComponentSystemBase.OnStartRunning()
    ComponentSystemBase.OnStopRunning()
    ComponentSystemBase.OnDestroy()
    ComponentSystemBase.ShouldRunSystem()
    ComponentSystemBase.GetArchetypeChunkComponentType<T>(Boolean)
    ComponentSystemBase.GetArchetypeChunkComponentTypeDynamic(ComponentType)
    ComponentSystemBase.GetArchetypeChunkBufferType<T>(Boolean)
    ComponentSystemBase.GetArchetypeChunkSharedComponentType<T>()
    ComponentSystemBase.GetArchetypeChunkEntityType()
    ComponentSystemBase.GetComponentDataFromEntity<T>(Boolean)
    ComponentSystemBase.GetBufferFromEntity<T>(Boolean)
    ComponentSystemBase.RequireForUpdate(EntityQuery)
    ComponentSystemBase.RequireSingletonForUpdate<T>()
    ComponentSystemBase.HasSingleton<T>()
    ComponentSystemBase.GetSingleton<T>()
    ComponentSystemBase.SetSingleton<T>(T)
    ComponentSystemBase.GetSingletonEntity<T>()
    ComponentSystemBase.GetEntityQuery(ComponentType[])
    ComponentSystemBase.GetEntityQuery(NativeArray<ComponentType>)
    ComponentSystemBase.GetEntityQuery(EntityQueryDesc[])
    Namespace: Unity.Entities
    Syntax
    public abstract class ComponentSystem : ComponentSystemBase
    Remarks

    Implement a ComponentSystem subclass for systems that perform their work on the main thread or that use Jobs not specifically optimized for ECS. To use the ECS-specific Jobs, such as Unity.Entities.IJobForEach`1 or IJobChunk, implement JobComponentSystem instead.

    Properties

    Entities

    This system's query builder object.

    Declaration
    protected EntityQueryBuilder Entities { get; }
    Property Value
    Type Description
    EntityQueryBuilder

    Use to select and iterate over entities.

    PostUpdateCommands

    This system's EntityCommandBuffer.

    Declaration
    public EntityCommandBuffer PostUpdateCommands { get; }
    Property Value
    Type Description
    EntityCommandBuffer

    A queue of entity-related commands to playback after the system's update function finishes.

    Remarks

    When iterating over a collection of entities with Entities, the system prohibits structural changes that would invalidate that collection. Such changes include creating and destroying entities, adding or removing components, and changing the value of shared components.

    Instead, add structural change commands to this PostUpdateCommands command buffer. The system executes commands added to this command buffer in order after this system's OnUpdate() function returns. PostUpdateCommands are created with a PlaybackPolicy.SinglePlayback and RecordingMode.Managed.

    Methods

    InitEntityQueryCache(Int32)

    Initializes this system's internal cache of EntityQuery objects to the specified number of queries.

    Declaration
    protected void InitEntityQueryCache(int cacheSize)
    Parameters
    Type Name Description
    Int32 cacheSize

    The initial capacity of the system's EntityQuery array.

    Remarks

    A system's entity query cache expands automatically as you add additional queries. However, initializing the cache to the correct size when you initialize a system is more efficient and avoids unnecessary, garbage-collected memory allocations.

    OnUpdate()

    Implement OnUpdate to perform the major work of this system.

    Declaration
    protected abstract void OnUpdate()
    Remarks

    The system invokes OnUpdate once per frame on the main thread when any of this system's EntityQueries match existing entities, or if the system has the AlwaysUpdateSystemAttribute.

    See Also
    ShouldRunSystem()

    Update()

    Declaration
    public override sealed void Update()
    Overrides
    ComponentSystemBase.Update()

    Extension Methods

    ComponentSystemBaseManagedComponentExtensions.HasSingleton<T>(ComponentSystemBase)
    ComponentSystemBaseManagedComponentExtensions.GetSingleton<T>(ComponentSystemBase)
    ComponentSystemBaseManagedComponentExtensions.SetSingleton<T>(ComponentSystemBase, T)
    JobForEachExtensions.GetEntityQueryForIJobForEach(ComponentSystemBase, Type)
    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on Monday, October 19, 2020