docs.unity3d.com
    Show / Hide Table of Contents

    Class EntityCommandBufferSystem

    A system that provides EntityCommandBuffer objects for other systems.

    Inheritance
    Object
    ComponentSystemBase
    ComponentSystem
    EntityCommandBufferSystem
    BeginFixedStepSimulationEntityCommandBufferSystem
    BeginInitializationEntityCommandBufferSystem
    BeginPresentationEntityCommandBufferSystem
    BeginSimulationEntityCommandBufferSystem
    BeginVariableRateSimulationEntityCommandBufferSystem
    EndFixedStepSimulationEntityCommandBufferSystem
    EndInitializationEntityCommandBufferSystem
    EndSimulationEntityCommandBufferSystem
    EndVariableRateSimulationEntityCommandBufferSystem
    Inherited Members
    ComponentSystem.PostUpdateCommands
    ComponentSystem.InitEntityQueryCache(Int32)
    ComponentSystem.Entities
    ComponentSystem.Update()
    ComponentSystemBase.Enabled
    ComponentSystemBase.EntityQueries
    ComponentSystemBase.GlobalSystemVersion
    ComponentSystemBase.LastSystemVersion
    ComponentSystemBase.EntityManager
    ComponentSystemBase.World
    ComponentSystemBase.SystemHandleUntyped
    ComponentSystemBase.Time
    ComponentSystemBase.OnCreateForCompiler()
    ComponentSystemBase.OnStartRunning()
    ComponentSystemBase.OnStopRunning()
    ComponentSystemBase.ShouldRunSystem()
    ComponentSystemBase.GetComponentTypeHandle<T>(Boolean)
    ComponentSystemBase.GetDynamicComponentTypeHandle(ComponentType)
    ComponentSystemBase.GetBufferTypeHandle<T>(Boolean)
    ComponentSystemBase.GetSharedComponentTypeHandle<T>()
    ComponentSystemBase.GetDynamicSharedComponentTypeHandle(ComponentType)
    ComponentSystemBase.GetEntityTypeHandle()
    ComponentSystemBase.GetComponentDataFromEntity<T>(Boolean)
    ComponentSystemBase.GetBufferFromEntity<T>(Boolean)
    ComponentSystemBase.GetStorageInfoFromEntity()
    ComponentSystemBase.RequireForUpdate(EntityQuery)
    ComponentSystemBase.RequireSingletonForUpdate<T>()
    ComponentSystemBase.HasSingleton<T>()
    ComponentSystemBase.GetSingleton<T>()
    ComponentSystemBase.TryGetSingleton<T>(T)
    ComponentSystemBase.SetSingleton<T>(T)
    ComponentSystemBase.GetSingletonEntity<T>()
    ComponentSystemBase.TryGetSingletonEntity<T>(Entity)
    ComponentSystemBase.GetEntityQuery(ComponentType[])
    ComponentSystemBase.GetEntityQuery(NativeArray<ComponentType>)
    ComponentSystemBase.GetEntityQuery(EntityQueryDesc[])
    Namespace: Unity.Entities
    Syntax
    public abstract class EntityCommandBufferSystem : ComponentSystem
    Remarks

    Each system that uses the EntityCommandBuffer provided by a command buffer system must call CreateCommandBuffer() to create its own command buffer instance. This buffer system executes each of these separate command buffers in the order that you created them. The commands are executed during this system's OnUpdate() function.

    When you write to a command buffer from a Job, you must add the JobHandle of that Job to the buffer system's dependency list with AddJobHandleForProducer(JobHandle).

    If you write to a command buffer from a Job that runs in parallel (and this includes both and IJobChunk), you must use the concurrent version of the command buffer (AsParallelWriter()).

    Executing the commands in an EntityCommandBuffer invokes the corresponding functions of the EntityManager. Any structural change, such as adding or removing entities, adding or removing components from entities, or changing shared component values, creates a sync-point in your application. At a sync point, all Jobs accessing entity components must complete before new Jobs can start. Such sync points make it difficult for the Job scheduler to fully utilize available computing power. To avoid sync points, you should use as few entity command buffer systems as possible.

    The default ECS World code creates a ComponentSystemGroup setup with three main groups, InitializationSystemGroup, SimulationSystemGroup, and PresentationSystemGroup. Each of these main groups provides an existing EntityCommandBufferSystem executed at the start and the end of other, child systems.

    Note that unused command buffers systems do not create sync points because there are no commands to execute and thus no structural changes created.

    The EntityCommandBufferSystem class is abstract, so you must implement a subclass to create your own entity command buffer system. However, none of its methods are abstract, so you do not need to implement your own logic. Typically, you create an EntityCommandBufferSystem subclass to create a named buffer system for other systems to use and update it at an appropriate place in a custom ComponentSystemGroup setup.

    Methods

    Name Description
    AddJobHandleForProducer(JobHandle)

    Adds the specified JobHandle to this system's list of dependencies.

    CreateCommandBuffer()

    Creates an EntityCommandBuffer and adds it to this system's list of command buffers.

    OnCreate()

    Initializes this command buffer system.

    OnDestroy()

    Destroys this system, executing any pending command buffers first.

    OnUpdate()

    Executes the command buffers in this system in the order they were created.

    Extension Methods

    ComponentSystemBaseManagedComponentExtensions.GetSingleton<T>(ComponentSystemBase)
    ComponentSystemBaseManagedComponentExtensions.SetSingleton<T>(ComponentSystemBase, T)
    In This Article
    • Methods
    • Extension Methods
    Back to top
    Terms of use
    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