### Start(ref DownloadStatus) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.Content.ContentDownloadService.DownloadOperation.Start.html Starts the download operation and updates the provided status. ```APIDOC ## Start(ref DownloadStatus) ### Description Starts the download operation. ### Method Start ### Signature `public void Start(ref ContentDownloadService.DownloadStatus status)` ### Parameters - **status** (ContentDownloadService.DownloadStatus) - The status will be updated when Start is called. ``` -------------------------------- ### AddJobHandleForProducer Example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.EntityCommandBufferSystem.AddJobHandleForProducer.html Example code showing how to use a default EntityCommandBufferSystem with an IJobEntity job and register the job's dependency with the playback system. ```APIDOC ## AddJobHandleForProducer ### Description Registers a job handle as a producer of commands for the EntityCommandBufferSystem, ensuring the system waits for the job before playing back the command buffer. ### Method AddJobHandleForProducer(JobHandle) ### Parameters - **jobHandle** (JobHandle) - The job handle of the producer job that writes to the command buffer. ### Example ```csharp public struct ProcessInfo : IComponentData { public float Value; } public struct ProcessCompleteTag : IComponentData { } [BurstCompile] public partial struct ProcessInBackgroundJob : IJobEntity { public EntityCommandBuffer.ParallelWriter ConcurrentCommands; public void Execute(Entity entity, [ChunkIndexInQuery] int chunkIndex, in ProcessInfo info) { // ...hypothetical processing goes here... // Remove ProcessInfo and add a ProcessCompleteTag... ConcurrentCommands.RemoveComponent(chunkIndex, entity); ConcurrentCommands.AddComponent(chunkIndex, entity); } } public partial class AsyncProcessJobSystem : SystemBase { protected override void OnUpdate() { // Get a reference to the system that will play back var ecbSystem = World.GetOrCreateSystemManaged(); var ecb = ecbSystem.CreateCommandBuffer(); // Pass the command buffer to the writer job, using its ParallelWriter interface var job = new ProcessInBackgroundJob { ConcurrentCommands = ecb.AsParallelWriter(), }; Dependency = job.ScheduleParallel(Dependency); // Register the writer job with the playback system as an input dependency ecbSystem.AddJobHandleForProducer(Dependency); } } ``` ``` -------------------------------- ### DynamicBuffer example with IBufferElementData and IJobEntity Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.DynamicBuffer-1.html Complete example defining a FloatBufferElement with implicit conversions and a system that sums all buffer values using a job. The job iterates over DynamicBuffer and accumulates the sum, which is then logged. ```csharp [InternalBufferCapacity(8)] public struct FloatBufferElement : IBufferElementData { // Actual value each buffer element will store. public float Value; // The following implicit conversions are optional, but can be convenient. public static implicit operator float(FloatBufferElement e) { return e.Value; } public static implicit operator FloatBufferElement(float e) { return new FloatBufferElement { Value = e }; } } public partial class DynamicBufferExample : SystemBase { partial struct DynamicBufferJob : IJobEntity { public float Sum; void Execute(DynamicBuffer buffer) { for (int i = 0; i < buffer.Length; i++) { Sum += buffer[i].Value; } } } protected override void OnUpdate() { var job = new DynamicBufferJob() { Sum = 0 }; job.Run(); Debug.Log("Sum of all buffers: " + job.Sum); } } ``` -------------------------------- ### Chaining WithAllRW calls (Duplicate Example) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.EntityQueryBuilder.WithAllRW.html Example showing how to chain WithAllRW calls to specify multiple required ReadWrite components in an EntityQuery. ```csharp var query = new EntityQueryBuilder(Allocator.Temp) .WithAll() .WithAllRW() .WithAllRW() .Build(this); ``` -------------------------------- ### MoveTowardsEntitySystem full example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/manual/systems-looking-up-data.html Complete example of a system that moves entities toward their target using ComponentLookup. It declares a read-only lookup, checks the target exists, and schedules a parallel job. ```csharp [RequireMatchingQueriesForUpdate] public partial class MoveTowardsEntitySystem : SystemBase { private EntityQuery query; [BurstCompile] private partial struct MoveTowardsJob : IJobEntity { // Read-only data stored (potentially) in other chunks [ReadOnly] public ComponentLookup EntityPositions; // Non-entity data public float deltaTime; public void Execute(ref LocalTransform transform, in Target target, in LocalToWorld entityPosition) { // Get the target Entity object Entity targetEntity = target.entity; // Check that the target still exists if (!EntityPositions.HasComponent(targetEntity)) return; // Update translation to move the chasing entity toward the target float3 targetPosition = EntityPositions[targetEntity].Position; float3 chaserPosition = transform.Position; float3 displacement = targetPosition - chaserPosition; transform.Position = chaserPosition + displacement * deltaTime; } } protected override void OnCreate() { // Select all entities that have Translation and Target Component query = this.GetEntityQuery ( typeof(LocalTransform), ComponentType.ReadOnly() ); } protected override void OnUpdate() { // Create the job var job = new MoveTowardsJob(); // Set the component data lookup field job.EntityPositions = GetComponentLookup(true); // Set non-ECS data fields job.deltaTime = SystemAPI.Time.DeltaTime; // Schedule the job using Dependency property Dependency = job.ScheduleParallel(query, Dependency); } } ``` -------------------------------- ### WithAny Usage Example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.EntityQueryBuilder.WithAny.html An example showing how to chain WithAny calls to require an entity to have at least one of the specified scale components. ```csharp var query = new EntityQueryBuilder(Allocator.Temp) .WithAll() .WithAny() .WithAny() .Build(this); ``` -------------------------------- ### Excluding standard vs chunk component example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.EntityQueryBuilder.WithAbsentChunkComponent.html Example showing how WithNone() excludes entities with a standard Player component, while WithNoneChunkComponent() excludes entities with a chunk Player component. The comments indicate which entities each query matches. ```csharp var entityWithPlayerComponent = EntityManager.CreateEntity(); EntityManager.AddComponent(entityWithPlayerComponent); var entityWithPlayerChunkComponent = EntityManager.CreateEntity(); EntityManager.AddComponent(entityWithPlayerChunkComponent, ComponentType.ChunkComponent()); // This query will only match entityWithPlayerChunkComponent, excluding entityWithPlayerComponent var noPlayerQuery = new EntityQueryBuilder(Allocator.Temp) .WithNone() .Build(this); // This query will only match entityWithPlayerComponent, excluding entityWithPlayerChunkComponent var noChunkPlayerQuery = new EntityQueryBuilder(Allocator.Temp) .WithNoneChunkComponent() .Build(this); ``` -------------------------------- ### Hash128 GUID { get; } Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.Build.IEntitiesPlayerSettings.GUID.html Gets the unique ID of the settings asset. ```APIDOC ## Hash128 GUID { get; } ### Description Gets the unique ID of the settings asset. ### Declaration ``` Hash128 GUID { get; } ``` ### Property Value | Type | Description | |------|-------------| | Hash128 | The unique ID of the settings asset. | ``` -------------------------------- ### HelloWorld.cs script Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/manual/ecs-workflow-example-starter.html A complete example containing an unmanaged IComponentData struct and an ISystem that creates an entity and logs its message. ```csharp using Unity.Entities; using Unity.Collections; using UnityEngine; // This is an example of an unmanaged ECS component. public struct HelloComponent : IComponentData { // FixedString32Bytes is used instead of string, because // struct IComponentData can only contain unmanaged types. public FixedString32Bytes Message; } public partial struct ExampleSystem : ISystem { public void OnCreate(ref SystemState state) { var entity = state.EntityManager.CreateEntity(); // Initialize and add a HelloComponent component to the entity. state.EntityManager.AddComponentData(entity, new HelloComponent { Message = "Hello ECS World" }); // Set the name of the entity to make it easier to identify it. // Note: the entity Name property only exists in the Editor. state.EntityManager.SetName(entity, "Hello World Entity"); } public void OnUpdate(ref SystemState state) { // The query retrieves all entities with a HelloComponent component. foreach (var message in SystemAPI.Query>()) { Debug.Log(message.ValueRO.Message); } } } ``` -------------------------------- ### OnCreate(ref SystemState) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.ISystem.OnCreate.html Called when this system is created. Use this method to set up system resources before the system starts running. ```APIDOC ## OnCreate(ref SystemState) ### Description Called when this system is created. Use this method to set up system resources before the system starts running. ### Method OnCreate ### Signature ``` [RequiredMember] void OnCreate(ref SystemState state) ``` ### Parameters - **state** (SystemState) - The SystemState backing this system instance. ### Remarks Implement an `OnCreate` function to set up system resources when it is created. `OnCreate` is invoked before the first time `OnStartRunning(ref SystemState)` and `OnUpdate(ref SystemState)` are invoked. ``` -------------------------------- ### public Hash128 AssetGUID { get; } Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.Serialization.EntityPrefabReference.AssetGUID.html Gets the prefab GUID represented by this EntityPrefabReference. ```APIDOC ## AssetGUID ### Description Returns the prefab GUID. ### Declaration ``` public Hash128 AssetGUID { get; } ``` ### Property Value | Type | Description | |------|-------------| | Hash128 | The prefab GUID. | ``` -------------------------------- ### GetServerGUID() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.Build.DotsGlobalSettings.GetServerGUID.html Gets the GUID of the Server asset. Returns a Hash128 value representing the GUID. ```APIDOC ## GetServerGUID() ### Description Gets the GUID of the Server asset. ### Method GetServerGUID ### Declaration public Hash128 GetServerGUID() ### Returns - **Hash128** - Returns the GUID of the Server asset. ``` -------------------------------- ### OnCreate() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.ComponentSystemBase.OnCreate.html Called when this system is created. Implement this method to set up system resources. It is invoked before the first time OnStartRunning() and OnUpdate are invoked. ```APIDOC ## OnCreate() ### Description Called when this system is created. Implement this method to set up system resources. It is invoked before the first time OnStartRunning() and OnUpdate are invoked. ### Method OnCreate ### Declaration ``` [RequiredMember] protected virtual void OnCreate() ``` ### Remarks Implement an OnCreate() function to set up system resources when it is created. OnCreate is invoked before the first time OnStartRunning() and OnUpdate are invoked. ``` -------------------------------- ### GetSceneGUID() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.IBaker.GetSceneGUID.html Gets the GUID of the current scene. Returns a Hash128 value representing the scene GUID. ```APIDOC ## GetSceneGUID() ### Description Gets the GUID of the current scene. ### Method GetSceneGUID() ### Declaration public Hash128 GetSceneGUID() ### Returns - **Hash128** - The scene GUID ``` -------------------------------- ### StartDownload(string, string) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.Content.ContentDownloadService.DownloadOperation.StartDownload.html This method is called when the download operation can begin downloading its data. It takes the remote path and a local temporary path as parameters. ```APIDOC ## StartDownload(string, string) ### Description Called when the operation can begin downloading its data. ### Method StartDownload ### Signature protected abstract void StartDownload(string remotePath, string localTmpPath) ### Parameters - **remotePath** (string) - The remote path of the data. This is typically a url. - **localTmpPath** (string) - The local path to download the data to. This file will be moved to the final path once completed. ``` -------------------------------- ### GetPathFromGUID(Hash128) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Scenes.ResourceCatalogData.GetPathFromGUID.html Gets the path of a resource from a GUID. ```APIDOC ## GetPathFromGUID(Hash128) ### Description Gets the path of a resource from a GUID. ### Declaration ```csharp public string GetPathFromGUID(Hash128 guid) ``` ### Parameters - **guid** (Hash128) - The GUID of the resource. ### Returns - **string** - Returns the path of the resource. ``` -------------------------------- ### BeginPresentationEntityCommandBufferSystem.OnCreate() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.BeginPresentationEntityCommandBufferSystem.html Initializes this command buffer system. This method is called when the system is created and sets up any necessary state. ```APIDOC ## OnCreate() ### Description Initializes this command buffer system. This method is called when the system is created and sets up any necessary state. ### Method OnCreate() ### Parameters None ### Returns void ### Remarks This method is part of the system lifecycle and is called automatically by the ECS framework. ``` -------------------------------- ### GetSceneGUID(ref SystemState, string) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Scenes.SceneSystem.GetSceneGUID.html Gets the GUID for a scene path or name. This is a slow method; it is best to use the GUID directly. ```APIDOC ## GetSceneGUID(ref SystemState, string) ### Description Gets the GUID for a scene path or name. This is a slow method; it is best to use the GUID directly. ### Method GetSceneGUID ### Signature public static Hash128 GetSceneGUID(ref SystemState state, string scenePath) ### Parameters - **state** (SystemState) - The entity system state. - **scenePath** (string) - The scene path or name. ### Returns - **Hash128** - True if the scene GUID exists. ``` -------------------------------- ### Initialize(string) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.ICustomBootstrap.Initialize.html Documentation for the ICustomBootstrap.Initialize method, which is called during default world initialization to allow custom bootstrap logic. ```APIDOC ## Initialize(string) ### Description Called during default world initialization to give the application a chance to set up additional worlds beyond (or instead of) the default world, and to perform additional one-time initialization before any worlds are created. ### Method Initialize ### Signature bool Initialize(string defaultWorldName) ### Parameters - **defaultWorldName** (string) - The name of the default World that will be created. ### Returns - **bool** - true if the bootstrap has performed initialization, or false if default world initialization should be performed. ### Remarks If this method returns true, it must also set DefaultGameObjectInjectionWorld to the world that GameObject-based code and the Editor integration should use. Unity asserts if the property is still null. ``` -------------------------------- ### SceneGUID Property Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Scenes.SubScene.SceneGUID.html Gets the GUID of the SceneAsset as a Hash128 value. ```APIDOC ## Property SceneGUID ### Description Represents the GUID of the SceneAsset. ### Declaration ```csharp public Hash128 SceneGUID { get; } ``` ### Property Value | Type | Description | |------|-------------| | Hash128 | The GUID of the SceneAsset. | ``` -------------------------------- ### EntitiesJournaling.Records.Range(int, int) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.EntitiesJournaling.Records.html Gets a number of records starting from a specified index. ```APIDOC ## Method: Range(int, int) ### Description Gets a number of records starting from a specified index. ### Syntax public static Range(int startIndex, int count) ### Parameters - **startIndex** (int) - Required - The starting index. - **count** (int) - Required - The number of records to retrieve. ### Returns - A collection of records. ``` -------------------------------- ### OnStartRunning(ref SystemState) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Scenes.SceneSystem.html Callback invoked when the system starts running. ```APIDOC ## OnStartRunning(ref SystemState) ### Description Callback invoked when the system starts running. ### Method OnStartRunning ### Parameters - **state** (ref SystemState) - The system state. ``` -------------------------------- ### IsStarted Property Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.Content.ContentDownloadService.DownloadOperation.IsStarted.html Gets a value indicating whether the download operation has been started. ```APIDOC ## IsStarted Property ### Description Gets a value indicating whether the download operation has been started. Returns false if the operation is queued. ### Declaration ```csharp public bool IsStarted { get; } ``` ### Property Value | Type | Description | |------|-------------| | bool | True if the operation has been started; otherwise, false. | ``` -------------------------------- ### OnCreate() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.BeginFixedStepSimulationEntityCommandBufferSystem.OnCreate.html Initializes this command buffer system. This method is a protected override and should call base.OnCreate() to retain default initialization logic. ```APIDOC ## OnCreate() ### Description Initializes this command buffer system. ### Declaration ``` protected override void OnCreate() ``` ### Overrides EntityCommandBufferSystem.OnCreate() ### Remarks If you override this method, you should call `base.OnCreate()` to retain the default initialization logic. ``` -------------------------------- ### GetSubScenes(GUID) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Scenes.Editor.EditorEntityScenes.html Gets all the sub scenes embedded in a scene. This method is part of the EditorEntityScenes static class and is used to retrieve sub scenes associated with a given scene GUID. ```APIDOC ## GetSubScenes(GUID) ### Description Gets all the sub scenes embedded in a scene. ### Method GetSubScenes ### Signature public static GetSubScenes(GUID) ### Parameters - **GUID** (GUID) - Required - The GUID of the scene to get sub scenes from. ### Returns - The sub scenes embedded in the scene. ``` -------------------------------- ### Initialize(string defaultWorldName, bool editorWorld = false) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.DefaultWorldInitialization.Initialize.html Initializes the default world or runs ICustomBootstrap if one is available. Creates a new World with the specified name, optionally filtering for editor worlds. ```APIDOC ## Initialize(string defaultWorldName, bool editorWorld = false) ### Description Initializes the default world or runs ICustomBootstrap if one is available. Creates a new World with the specified name, optionally filtering for editor worlds. ### Method Initialize ### Signature public static World Initialize(string defaultWorldName, bool editorWorld = false) ### Parameters - **defaultWorldName** (string) - Required - The name of the world that will be created. Unless there is a custom bootstrap. - **editorWorld** (bool) - Optional - Editor worlds by default only include systems with [WorldSystemFilter(WorldSystemFilterFlags.Editor)]. If editorWorld is true, ICustomBootstrap will not be used. ### Returns - **World** - The initialized World object. ``` -------------------------------- ### ScratchpadAllocator.Function Property Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.ScratchpadAllocator.Function.html Gets the AllocatorManager.TryFunction delegate for the allocator. This property is required for custom allocator installation. ```APIDOC ## Property: Function ### Description Gets the AllocatorManager.TryFunction delegate for the allocator. This property is required for custom allocator installation. ### Declaration ```csharp [ExcludeFromBurstCompatTesting("Returns managed delegate")] public AllocatorManager.TryFunction Function { get; } ``` ### Property Value | Type | Description | |------|-------------| | AllocatorManager.TryFunction | The delegate used by the allocator manager. | ### Implements - AllocatorManager.IAllocator.Function ``` -------------------------------- ### BeginInitializationEntityCommandBufferSystem.OnCreate() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.BeginInitializationEntityCommandBufferSystem.html Initializes this command buffer system. This method is called when the system is created and sets up the command buffer system. ```APIDOC ## OnCreate() ### Description Initializes this command buffer system. ### Method OnCreate() ### Parameters None ### Return Value None ### Remarks This method is part of the BeginInitializationEntityCommandBufferSystem class and is called during system creation. ``` -------------------------------- ### public int Offset Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.PackedComponentDataChange.Offset.html Gets the start offset for this data change. This is the field offset and NOT the payload offset. ```APIDOC ## public int Offset ### Description Gets the start offset for this data change. This is the field offset and NOT the payload offset. ### Syntax ```csharp public int Offset ``` ### Returns | Type | Description | |------|-------------| | int | | ### Remarks This is the field offset and NOT the payload offset. ``` -------------------------------- ### BeginFixedStepSimulationEntityCommandBufferSystem.OnCreate() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.BeginFixedStepSimulationEntityCommandBufferSystem.html Initializes this command buffer system. This method is called when the system is created and can be overridden to provide custom initialization logic. ```APIDOC ## OnCreate() ### Description Initializes this command buffer system. This method is called when the system is created and can be overridden to provide custom initialization logic. ### Method OnCreate() ### Syntax protected override void OnCreate() ### Remarks This method is part of the EntityCommandBufferSystem lifecycle and is called automatically by the Unity.Entities framework. ``` -------------------------------- ### GetSettingsAsset(Hash128) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.Build.DotsGlobalSettings.GetSettingsAsset.html Gets the IEntitiesPlayerSettings settings asset corresponding to the provided guid. Returns the settings asset or null if not found. ```APIDOC ## GetSettingsAsset(Hash128) ### Description Gets the IEntitiesPlayerSettings settings asset corresponding to the guid. ### Method GetSettingsAsset(Hash128 guid) ### Parameters - **guid** (Hash128) - The unique ID of the build settings asset. ### Returns - **IEntitiesPlayerSettings** - Returns the settings asset corresponding to the guid, or null if not found. ### Declaration public IEntitiesPlayerSettings GetSettingsAsset(Hash128 guid) ``` -------------------------------- ### Init(RemoteContentLocation, string, string) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.Content.ContentDownloadService.DownloadOperation.Init.html Initializes the download operation with the content location, temporary download path, and final destination path. ```APIDOC ## Init(RemoteContentLocation, string, string) ### Description Initializes the download operation with the information needed to start. ### Method Init ### Signature public void Init(RemoteContentLocation loc, string tmpPath, string finalPath) ### Parameters - **loc** (RemoteContentLocation) - The content location. - **tmpPath** (string) - The temporary path to download to. - **finalPath** (string) - The final path to copy to once the download completes. ``` -------------------------------- ### ICustomBootstrap Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.html When entering playmode or the game starts in the Player a default world is created. Sometimes you need multiple worlds to be setup when the game starts or perform some custom world initialization. This lets you override the bootstrap of game code world creation. ```APIDOC ## ICustomBootstrap ### Description When entering playmode or the game starts in the Player a default world is created. Sometimes you need multiple worlds to be setup when the game starts or perform some custom world initialization. This lets you override the bootstrap of game code world creation. ### Interface ICustomBootstrap ### Usage Implement this interface to customize world creation during game startup. ``` -------------------------------- ### Initialize(int, int, bool, int) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.Scratchpad.Initialize.html Initializes a Scratchpad with the specified number of allocators, initial size, global flag, and global index. ```APIDOC ## Initialize(int, int, bool, int) ### Description Initializes a Scratchpad with the specified number of allocators, initial size, global flag, and global index. ### Method Initialize ### Signature [ExcludeFromBurstCompatTesting("Accesses managed delegate")] public void Initialize(int numScratchpadAllocators, int initialSizeInBytes = 32768, bool isGlobal = false, int globalIndex = 0) ### Parameters - **numScratchpadAllocators** (int) - Required - The number of ScratchpadAllocators the created Scratchpad should contain. - **initialSizeInBytes** (int) - Optional - The initial size of the Scratchpad in bytes. Set to 32,768 by default. - **isGlobal** (bool) - Optional - Flag indicating if the allocator is a global allocator. - **globalIndex** (int) - Optional - Base index into the global function table of the allocator to be created. ### Return Value void ``` -------------------------------- ### Create and record to an EntityCommandBuffer using EntityCommandBufferSystem Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/manual/systems-entity-command-buffer-automatic-playback.html This example demonstrates retrieving a system singleton to create an EntityCommandBuffer and scheduling a parallel job to record commands. The EntityCommandBufferSystem will automatically handle the playback and disposal of the buffer. ```csharp // ... in a system. // Assume an EntityCommandBufferSystem exists named FooECBSystem. // This call to GetSingleton automatically registers the job so that // it gets completed by the ECB system. var singleton = SystemAPI.GetSingleton(); // Create a command buffer that will be played back // and disposed by MyECBSystem. EntityCommandBuffer ecb = singleton.CreateCommandBuffer(state.WorldUnmanaged); // An IJobEntity with no argument to Schedule implicitly // assigns its returned JobHandle to this.Dependency new MyParallelRecordingJob() { ecbParallel = ecb.AsParallelWriter() }.Schedule(); ``` -------------------------------- ### Get root entity using Parent chain (main-thread) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/manual/transforms-comparison.html Main-thread implementation to find the root entity by following Parent references until an entity with no Parent component is reached. Returns the starting entity unchanged if it is already a root. ```C# Entity Root(ref SystemState state, Entity e) { while (SystemAPI.TryGetComponent(e, out var parent)) e = parent.Value; return e; } ``` -------------------------------- ### ComputeWorldTransformMatrix: compute LocalToWorld before systems run Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/manual/transforms-helpers.html Shows how to use ComputeWorldTransformMatrix to get an entity's precise world-space transformation matrix before LocalToWorldSystem has run. The example creates a parent-child hierarchy, moves the parent, and then computes the child's LocalToWorld. Note that the operation is expensive and the lookups should be created in OnCreate and updated in OnUpdate. ```csharp public void Foo(ref SystemState state) { // Create a simple hierarchy Entity parentEntity = state.EntityManager.CreateEntity(typeof(LocalToWorld), typeof(LocalTransform)); state.EntityManager.SetComponentData(parentEntity, new LocalToWorld() { Value = float4x4.identity }); state.EntityManager.SetComponentData(parentEntity, LocalTransform.Identity); Entity childEntity = state.EntityManager.CreateEntity(typeof(LocalToWorld), typeof(LocalTransform), typeof(Parent)); state.EntityManager.SetComponentData(childEntity, new Parent() { Value = parentEntity }); state.EntityManager.SetComponentData(childEntity, new LocalToWorld() { Value = float4x4.identity }); state.EntityManager.SetComponentData(childEntity, LocalTransform.Identity); // Move the parent state.EntityManager.SetComponentData(parentEntity, LocalTransform.FromPosition(1, 2, 3)); // At this point, both the child's and the parent's LocalToWorld will still be identity, because // ParentSystem and LocalToWorldSystem have not run yet. float4x4 childLocalToWorldMatrix = SystemAPI.GetComponent(childEntity).Value; // Will be identity // The following should really be in an OnCreate() or similar. In that case, you will need to call // Lookup.Update in the OnUpdate(). ComponentLookup localTransformLookup = SystemAPI.GetComponentLookup(true); ComponentLookup parentLookup = SystemAPI.GetComponentLookup(true); ComponentLookup postTransformLookup = SystemAPI.GetComponentLookup(true); // If you absolutely need the child's up to date LocalToWorld before LocalToWorldSystem has run, this is how // you do it. It is an expensive operation, so use it carefully. TransformHelpers.ComputeWorldTransformMatrix(childEntity, out childLocalToWorldMatrix, ref localTransformLookup, ref parentLookup, ref postTransformLookup); } ``` -------------------------------- ### ParentSystem.OnCreate(ref SystemState) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Transforms.ParentSystem.html Called when the system is created. Use this method to initialize system state. ```APIDOC ## OnCreate(ref SystemState) ### Description Called when the system is created. Use this method to initialize system state. ### Method OnCreate ### Parameters - **state** (SystemState) - The system state. ### Remarks This method is part of the ISystem interface and is called once when the system is created. ``` -------------------------------- ### Clear method usage example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.DynamicBuffer-1.Clear.html Example call to buffer.Clear() to clear the buffer. ```csharp buffer.Clear(); ``` -------------------------------- ### OnCreate() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.BakingSystem.OnCreate.html Called when this system is created. Overrides ComponentSystemBase.OnCreate(). ```APIDOC ## OnCreate() ### Description Called when this system is created. ### Declaration ```csharp protected override void OnCreate() ``` ### Overrides ComponentSystemBase.OnCreate() ``` -------------------------------- ### BeginVariableRateSimulationEntityCommandBufferSystem.Singleton Methods Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.BeginVariableRateSimulationEntityCommandBufferSystem.Singleton.html Methods for creating and configuring entity command buffers through the BeginVariableRateSimulationEntityCommandBufferSystem.Singleton. ```APIDOC ## CreateCommandBuffer(WorldUnmanaged) ### Description Creates a command buffer for the parent system to play back. ### Method CreateCommandBuffer ### Parameters - **world** (WorldUnmanaged) - The world for which the command buffer is created. ### Returns - **EntityCommandBuffer** - The created command buffer. ``` ```APIDOC ## SetAllocator(Allocator) ### Description Sets the allocator that command buffers created with this singleton should be allocated with. ### Method SetAllocator ### Parameters - **allocator** (Allocator) - The allocator to use for command buffers. ### Returns - **void** - No return value. ``` ```APIDOC ## SetAllocator(AllocatorHandle) ### Description Sets the allocator that command buffers created with this singleton should be allocated with. ### Method SetAllocator ### Parameters - **allocator** (AllocatorHandle) - The allocator handle to use for command buffers. ### Returns - **void** - No return value. ``` ```APIDOC ## SetPendingBufferList(ref UnsafeList) ### Description Sets the list of command buffers to play back when this system updates. ### Method SetPendingBufferList ### Parameters - **list** (ref UnsafeList) - The list of command buffers to play back. ### Returns - **void** - No return value. ``` -------------------------------- ### RemoveRange Usage Example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.DynamicBuffer-1.RemoveRange.html A basic example showing how to call RemoveRange on a buffer instance. ```csharp buffer.RemoveRange(start, 5); ``` -------------------------------- ### Spawn prefab and add AnimatorInstanceRef in system Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/manual/reference-unity-objects.html Shows a system that queries entities with AnimatorPrefabRef and LocalToWorld, instantiates the referenced GameObject, positions it at the entity's transform, and adds an AnimatorInstanceRef component. ```csharp public partial struct SpawnAnimatedCubeSystem : ISystem { EntityQuery m_Query; public void OnCreate(ref SystemState state) { m_Query = SystemAPI.QueryBuilder() .WithAll() .WithNone() .Build(); state.RequireForUpdate(m_Query); } public void OnUpdate(ref SystemState state) { var entities = m_Query.ToEntityArray(state.WorldUpdateAllocator); foreach (var entity in entities) { var prefabRef = SystemAPI.GetComponent(entity); var worldTransform = SystemAPI.GetComponent(entity); //Instantiate the GO and place it at the entity's transform var rotatingCube = Object.Instantiate(prefabRef.Prefab.Value); rotatingCube.transform.SetPositionAndRotation(worldTransform.Position, worldTransform.Rotation); //Add the animator to the entity state.EntityManager.AddComponentData(entity, new AnimatorInstanceRef { Animator = rotatingCube.GetComponent() }); } } } ``` -------------------------------- ### DynamicBuffer.Insert Usage Example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.DynamicBuffer-1.Insert.html An example showing how to conditionally insert an element into a buffer at a specific index. ```csharp if (insertionIndex < buffer.Length) buffer.Insert(insertionIndex, 6); ``` -------------------------------- ### OnStartRunning() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.ComponentSystemBase.OnStartRunning.html Documentation for the OnStartRunning method of ComponentSystemBase. ```APIDOC ## OnStartRunning() ### Description Called before the first call to OnUpdate and when a system resumes updating after being stopped or disabled. ### Declaration ```csharp [RequiredMember] protected virtual void OnStartRunning() ``` ### Remarks If the EntityQuery objects defined for a system do not match any existing entities then the system skips updates until a successful match is found. Likewise, if you set Enabled to false, then the system stops running. In both cases, OnStopRunning() is called when a running system stops updating; OnStartRunning is called when it starts updating again. ``` -------------------------------- ### Initialize(string, string, string, Action) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.Content.ContentDeliveryGlobalState.Initialize.html Initializes the content delivery system with the specified remote URL root, cache path, initial content set, and update state callback. ```APIDOC ## Initialize(string remoteUrlRoot, string cachePath, string initialContentSet, Action updateStateFunc) ### Description Initializes the content delivery system. ### Method Initialize ### Signature public static void Initialize(string remoteUrlRoot, string cachePath, string initialContentSet, Action updateStateFunc) ### Parameters - **remoteUrlRoot** (string) - The remote url root in the form of "https://hostname.com/pathToContent/". If this parameter is not specified, content is assumed to be local. - **cachePath** (string) - The full local path of the content cache. This must be a directory that the application has read and write access to. - **initialContentSet** (string) - The initial set of content to download. The content sets are given names during the publish process and by default everything is added to the "all" set. - **updateStateFunc** (Action) - Callback action that will get called whenever the content update state changes. ### Return Value void ``` -------------------------------- ### CopyFrom(T[]) Example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.DynamicBuffer-1.CopyFrom.html Example of copying elements from a C# array into a dynamic buffer using CopyFrom. ```csharp int[] integerArray = { 1, 2, 3, 4, 5 }; buffer.CopyFrom(integerArray); ``` -------------------------------- ### Get world position with LocalToWorld.Position Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/manual/transforms-comparison.html Main-thread implementation to get the world-space position using SystemAPI.GetComponent and LocalToWorld.Position. ```C# float3 Position(ref SystemState state, Entity e) { return SystemAPI.GetComponent(e).Position; } ``` -------------------------------- ### WeakAssetReferenceLoadingSystem.OnCreate(ref SystemState) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Scenes.WeakAssetReferenceLoadingSystem.html Callback invoked when the system is created. ```APIDOC ## OnCreate(ref SystemState) ### Description Callback invoked when the system is created. ### Method OnCreate ### Signature public void OnCreate(ref SystemState state) ### Parameters - **state** (SystemState) - The system state. ### Remarks This method is part of the ISystem interface implementation. ``` -------------------------------- ### EnabledRefRW Properties Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.EnabledRefRW-1.html Properties to check validity, get null reference, and get or set the enabled value. ```APIDOC ## Properties ### IsValid Property that returns true if the reference is valid, false otherwise. ### Null Null value for this reference. ### ValueRO Property to get enabled value of this reference (true if enabled, false otherwise). ### ValueRW Property to get or set enabled value of this reference (true if enabled, false otherwise). ``` -------------------------------- ### BlobAssetStore Constructor Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.BlobAssetStore.html Initializes and returns an instance of BlobAssetStore. ```APIDOC ## BlobAssetStore(int) ### Description Initializes and returns an instance of BlobAssetStore. ### Syntax ```csharp public BlobAssetStore(int initialCapacity) ``` ### Parameters - **initialCapacity** (int) - Required - The initial capacity of the store. ``` -------------------------------- ### ISystemStartStop Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.html Optional interface for start/stop notifications on systems. ```APIDOC ## ISystemStartStop ### Description Optional interface for start/stop notifications on systems. ### Interface ISystemStartStop ### Usage Implement this interface on a system to receive start and stop notifications. ``` -------------------------------- ### Length { get; } Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.BlobArray-1.Length.html Gets the number of elements in the array. The value is assigned when the blob asset is created, so it is 0 before that. ```APIDOC ## Length Property ### Description Gets the number of elements in the BlobArray. ### Declaration public int Length { get; } ### Property Value - **int** - The number of elements in the array. ### Remarks Unity assigns the length of the array when you call CreateBlobAssetReference(AllocatorHandle), so until then this property returns 0. To get the number of elements before that point, use the Length property of the BlobBuilderArray that Allocate(ref BlobArray, int) returns. ``` -------------------------------- ### CopyFrom(DynamicBuffer) Example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.DynamicBuffer-1.CopyFrom.html Example of copying elements from another dynamic buffer into this buffer using CopyFrom. ```csharp buffer.CopyFrom(secondBuffer); ``` -------------------------------- ### Build and publish content update from C# script Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/manual/content-management-create-content-archives.html This code example shows how to build and publish a content update using the content archive build and publish APIs. It includes two methods: PublishExistingBuild prepares content files for publish, and CreateContentUpdate builds scenes from a player build without fully building the player. The example uses RemoteContentCatalogBuildUtility.PublishContent and BuildContent. ```csharp using System; using System.Collections.Generic; using System.IO; using Unity.Build.Classic; using Unity.Collections; using Unity.Scenes.Editor; using UnityEditor.Experimental; using UnityEngine; using UnityEditor; using System.Linq; using Unity.Build; using Unity.Build.Common; using Unity.Entities.Build; using Unity.Entities.Content; static class BuildUtilities { //prepares the content files for publish. The original files can be deleted or retained during this process by changing the last parameter of the PublishContent call. static void PublishExistingBuild() { var buildFolder = EditorUtility.OpenFolderPanel("Select Build To Publish", Path.GetDirectoryName(Application.dataPath), "Builds"); if (!string.IsNullOrEmpty(buildFolder)) { var streamingAssetsPath = $"{buildFolder}/{PlayerSettings.productName}_Data/StreamingAssets"; //the content sets are defined by the functor passed in here. RemoteContentCatalogBuildUtility.PublishContent(streamingAssetsPath, $"{buildFolder}-RemoteContent", f => new string[] { "all" }, true); } } //This method is somewhat complicated because it will build the scenes from a player build but without fully building the player. static void CreateContentUpdate() { var buildFolder = EditorUtility.OpenFolderPanel("Select Build To Publish", Path.GetDirectoryName(Application.dataPath), "Builds"); if (!string.IsNullOrEmpty(buildFolder)) { var buildTarget = EditorUserBuildSettings.activeBuildTarget; var tmpBuildFolder = Path.Combine(Path.GetDirectoryName(Application.dataPath), $"/Library/ContentUpdateBuildDir/{PlayerSettings.productName}"); var instance = DotsGlobalSettings.Instance; var playerGuid = instance.GetPlayerType() == DotsGlobalSettings.PlayerType.Client ? instance.GetClientGUID() : instance.GetServerGUID(); if (!playerGuid.IsValid) throw new Exception("Invalid Player GUID"); var subSceneGuids = new HashSet(); for (int i = 0; i < EditorBuildSettings.scenes.Length; i++) { var ssGuids = EditorEntityScenes.GetSubScenes(EditorBuildSettings.scenes[i].guid); foreach (var ss in ssGuids) subSceneGuids.Add(ss); } RemoteContentCatalogBuildUtility.BuildContent(subSceneGuids, playerGuid, buildTarget, tmpBuildFolder); var publishFolder = Path.Combine(Path.GetDirectoryName(Application.dataPath), "Builds", $"{buildFolder}-RemoteContent"); RemoteContentCatalogBuildUtility.PublishContent(tmpBuildFolder, publishFolder, f => new string[] { "all" }); } } } ``` -------------------------------- ### CopyFrom(NativeSlice) Example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.DynamicBuffer-1.CopyFrom.html Example of copying elements from a NativeSlice into a dynamic buffer using CopyFrom. ```csharp NativeSlice nativeSlice = new NativeSlice(nativeArray, 1, 3); buffer.CopyFrom(nativeSlice); ``` -------------------------------- ### EndInitializationEntityCommandBufferSystem.OnCreate() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.EndInitializationEntityCommandBufferSystem.html Initializes this command buffer system. This method is called when the system is created and sets up the command buffer system. ```APIDOC ## OnCreate() ### Description Initializes this command buffer system. ### Method OnCreate() ### Syntax ```csharp protected override void OnCreate() ``` ### Parameters None. ### Returns void ### Remarks This method is called when the system is created and sets up the command buffer system. ``` -------------------------------- ### CopyFrom(NativeArray) Example Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.DynamicBuffer-1.CopyFrom.html Example of copying elements from a NativeArray into a dynamic buffer using CopyFrom. ```csharp int[] sourceArray = { 1, 2, 3, 4, 5 }; NativeArray nativeArray = new NativeArray(source, Allocator.Persistent); buffer.CopyFrom(nativeArray); ``` -------------------------------- ### BeginInitializationEntityCommandBufferSystem.Singleton Methods Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.BeginInitializationEntityCommandBufferSystem.Singleton.html Methods for the BeginInitializationEntityCommandBufferSystem.Singleton struct. ```APIDOC ## CreateCommandBuffer(WorldUnmanaged) ### Description Creates a command buffer for the parent system to play back. ### Method CreateCommandBuffer(WorldUnmanaged) ### Parameters - **world** (WorldUnmanaged) - The world in which the command buffer is created. ### Returns EntityCommandBuffer - The created command buffer. ``` ```APIDOC ## SetAllocator(Allocator) ### Description Sets the allocator that command buffers created with this singleton should be allocated with. ### Method SetAllocator(Allocator) ### Parameters - **allocator** (Allocator) - The allocator to use for command buffers created with this singleton. ``` ```APIDOC ## SetAllocator(AllocatorHandle) ### Description Sets the allocator that command buffers created with this singleton should be allocated with. ### Method SetAllocator(AllocatorHandle) ### Parameters - **allocator** (AllocatorHandle) - The allocator handle to use for command buffers created with this singleton. ``` ```APIDOC ## SetPendingBufferList(ref UnsafeList) ### Description Sets the list of command buffers to play back when this system updates. ### Method SetPendingBufferList(ref UnsafeList) ### Parameters - **list** (ref UnsafeList) - The list of command buffers to play back when this system updates. ``` -------------------------------- ### OnStartRunning(ref SystemState) Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Scenes.SceneSystem.OnStartRunning.html Documentation for the OnStartRunning method of the SceneSystem class, which is called when the system starts running. ```APIDOC ## OnStartRunning(ref SystemState) ### Description Callback invoked when the system starts running. ### Method OnStartRunning ### Signature public void OnStartRunning(ref SystemState state) ### Parameters - **state** (SystemState) - The entity system state. ### Implements ISystemStartStop.OnStartRunning(ref SystemState) ``` -------------------------------- ### Set and get chunk component via entity's chunk Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/manual/components-chunk-use.html Shows how to get the chunk of an entity and then set and get the chunk component value using that chunk. Uses EntityManager.GetChunk, SetChunkComponentData, and GetChunkComponentData. Assumes ExampleChunkComponent exists. ```csharp private void ChunkComponentExample(Entity e) { var entityChunk = EntityManager.GetChunk(e); // Sets the ExampleChunkComponent value of the entity's chunk. EntityManager.SetChunkComponentData(entityChunk, new ExampleChunkComponent { Value = 6 }); // Gets the ExampleChunkComponent value of the entity's chunk. ExampleChunkComponent exampleChunkComponent = EntityManager.GetChunkComponentData(e); Debug.Log(exampleChunkComponent.Value) // 6 } ``` -------------------------------- ### OnStartRunning() Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.UpdateWorldTimeSystem.OnStartRunning.html Runs just before the system's first update after it is enabled. This method is an override of ComponentSystemBase.OnStartRunning(). ```APIDOC ## OnStartRunning() ### Description Runs just before the system's first update after it is enabled. ### Declaration ```csharp protected override void OnStartRunning() ``` ### Overrides ComponentSystemBase.OnStartRunning() ### Remarks Ensure that the final elapsedTime of the very first OnUpdate call is the original Time.ElapsedTime value (usually zero) without a deltaTime applied. Effectively, this code preemptively counteracts the first OnUpdate call. ``` -------------------------------- ### bool HasNativeContainer { get; } Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/api/Unity.Entities.TypeIndex.HasNativeContainer.html Gets a value indicating whether the component type contains a NativeContainerAttribute decorated member. ```APIDOC ## [PROPERTY] bool HasNativeContainer { get; } ### Description The component type contains a NativeContainerAttribute decorated member. NativeContainer members found in nested member types will also cause this property to return true. ### Property Value - **bool** - Returns true if the component type contains a member decorated with the NativeContainerAttribute, including nested member types. ### Declaration ```csharp public bool HasNativeContainer { get; } ``` ``` -------------------------------- ### Create a blob asset with BlobBuilder Source: https://docs.unity3d.com/Packages/com.unity.entities%406.6/manual/blob-assets-create.html Shows the full workflow: create a BlobBuilder, construct the root, fill data, create a BlobAssetReference, and dispose the builder. The example stores a MarketData struct with two float fields. ```csharp struct MarketData { public float PriceOranges; public float PriceApples; } BlobAssetReference CreateMarketData() { // Create a new builder that will use temporary memory to construct the blob asset var builder = new BlobBuilder(Allocator.Temp); // Construct the root object for the blob asset. Notice the use of `ref`. ref MarketData marketData = ref builder.ConstructRoot(); // Now fill the constructed root with the data: // Apples compare to Oranges in the universally accepted ratio of 2 : 1 . marketData.PriceApples = 2f; marketData.PriceOranges = 4f; // Now copy the data from the builder into its final place, which will // use the persistent allocator var result = builder.CreateBlobAssetReference(Allocator.Persistent); // Make sure to dispose the builder itself so all internal memory is disposed. builder.Dispose(); return result; } ```