docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class EntityCommandBufferSystem

    A system that provides EntityCommandBuffer objects for other systems.

    Inheritance
    object
    ComponentSystemBase
    SystemBase
    EntityCommandBufferSystem
    BeginFixedStepSimulationEntityCommandBufferSystem
    BeginInitializationEntityCommandBufferSystem
    BeginPresentationEntityCommandBufferSystem
    BeginSimulationEntityCommandBufferSystem
    BeginVariableRateSimulationEntityCommandBufferSystem
    EndFixedStepSimulationEntityCommandBufferSystem
    EndInitializationEntityCommandBufferSystem
    EndSimulationEntityCommandBufferSystem
    EndVariableRateSimulationEntityCommandBufferSystem
    Inherited Members
    SystemBase.Dependency
    SystemBase.CheckedStateRef
    SystemBase.CompleteDependency()
    SystemBase.Entities
    SystemBase.Job
    SystemBase.Update()
    SystemBase.GetComponent<T>(Entity)
    SystemBase.SetComponent<T>(Entity, T)
    SystemBase.HasComponent<T>(Entity)
    SystemBase.HasBuffer<T>(Entity)
    SystemBase.GetComponentLookup<T>(bool)
    SystemBase.GetComponentDataFromEntity<T>(bool)
    SystemBase.GetBuffer<T>(Entity, bool)
    SystemBase.GetBufferLookup<T>(bool)
    SystemBase.GetBufferFromEntity<T>(bool)
    SystemBase.GetEntityStorageInfoLookup()
    SystemBase.GetStorageInfoFromEntity()
    SystemBase.Exists(Entity)
    ComponentSystemBase.Enabled
    ComponentSystemBase.EntityQueries
    ComponentSystemBase.GlobalSystemVersion
    ComponentSystemBase.LastSystemVersion
    ComponentSystemBase.EntityManager
    ComponentSystemBase.World
    ComponentSystemBase.SystemHandle
    ComponentSystemBase.SystemHandleUntyped
    ComponentSystemBase.Time
    ComponentSystemBase.WorldUpdateAllocator
    ComponentSystemBase.OnStartRunning()
    ComponentSystemBase.OnStopRunning()
    ComponentSystemBase.ShouldRunSystem()
    ComponentSystemBase.GetComponentTypeHandle<T>(bool)
    ComponentSystemBase.GetDynamicComponentTypeHandle(ComponentType)
    ComponentSystemBase.GetBufferTypeHandle<T>(bool)
    ComponentSystemBase.GetSharedComponentTypeHandle<T>()
    ComponentSystemBase.GetDynamicSharedComponentTypeHandle(ComponentType)
    ComponentSystemBase.GetEntityTypeHandle()
    ComponentSystemBase.RequireForUpdate(EntityQuery)
    ComponentSystemBase.RequireAnyForUpdate(params EntityQuery[])
    ComponentSystemBase.RequireAnyForUpdate(NativeArray<EntityQuery>)
    ComponentSystemBase.RequireForUpdate<T>()
    ComponentSystemBase.RequireSingletonForUpdate<T>()
    ComponentSystemBase.HasSingleton<T>()
    ComponentSystemBase.GetSingleton<T>()
    ComponentSystemBase.GetSingletonRW<T>()
    ComponentSystemBase.GetSingletonBuffer<T>(bool)
    ComponentSystemBase.TryGetSingleton<T>(out T)
    ComponentSystemBase.TryGetSingletonBuffer<T>(out DynamicBuffer<T>)
    ComponentSystemBase.SetSingleton<T>(T)
    ComponentSystemBase.GetSingletonEntity<T>()
    ComponentSystemBase.TryGetSingletonEntity<T>(out Entity)
    ComponentSystemBase.GetEntityQuery(params ComponentType[])
    ComponentSystemBase.GetEntityQuery(NativeArray<ComponentType>)
    ComponentSystemBase.GetEntityQuery(params EntityQueryDesc[])
    ComponentSystemBase.GetEntityQuery(in EntityQueryBuilder)
    Namespace: Unity.Entities
    Assembly: Unity.Entities.dll
    Syntax
    public abstract class EntityCommandBufferSystem : SystemBase
    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 IJobEntity 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.

    Fields

    Name Description
    m_PendingBuffers

    List of command buffers that this system has allocated, which are played back and disposed of when the system updates.

    Properties

    Name Description
    PendingBuffers

    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.

    CreateCommandBuffer(ref UnsafeList<EntityCommandBuffer>, AllocatorHandle, WorldUnmanaged)

    Creates a command buffer, sets it up, and appends it to a list of command buffers.

    CreateCommandBuffer(ref UnsafeList<EntityCommandBuffer>, WorldUnmanaged)

    Creates a command buffer that allocates from a World's Update Allocator, sets it up, and appends it to a list of command buffers.

    OnCreate()

    Initializes this command buffer system.

    OnDestroy()

    Destroys this system. Any pending command buffers will be disposed, but their commands will NOT be played back.

    OnUpdate()

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

    Extension Methods

    ComponentSystemBaseManagedComponentExtensions.GetSingletonRW<T>(ComponentSystemBase)
    ComponentSystemBaseManagedComponentExtensions.GetSingleton<T>(ComponentSystemBase)
    ComponentSystemBaseManagedComponentExtensions.SetSingleton<T>(ComponentSystemBase, T)
    ECBExtensionMethods.RegisterSingleton<T>(EntityCommandBufferSystem, ref UnsafeList<EntityCommandBuffer>, WorldUnmanaged)
    ECBExtensionMethods.RegisterSingleton<T>(EntityCommandBufferSystem, ref UnsafeList<EntityCommandBuffer>, WorldUnmanaged, string)
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)