Skip to content

Game.Simulation.UpdateFrame

Assembly:
Namespace: Game.Simulation

Type: struct

Base: System.ValueType, ISharedComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a lightweight shared component that holds a frame index used by the simulation update system. This struct is intended to be used as a shared component in Unity's ECS (to group or tag entities by a simulation frame) and supports the game's serialization system via the ISerializable interface so the frame index can be written to/read from the game's writer/reader implementations.


Fields

  • public uint m_Index
    Holds the numeric index of the update frame. Typically used to mark or identify the frame number for simulation logic, filtering, or debugging. Because this is a shared component, changing this value on an entity will affect grouping of entities in ECS queries that filter by this shared component.

Properties

  • This type does not declare any properties.

Constructors

  • public UpdateFrame(uint index)
    Creates a new UpdateFrame with the given frame index. Use this to construct the shared component before assigning it to an entity or serializing it.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the stored frame index using the provided writer. The writer is expected to have a Write(uint) method.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes the frame index from the provided reader into this instance. The reader is expected to support Read(out uint).

Usage Example

// Constructing and using UpdateFrame as a shared component
var frame = new UpdateFrame(42);

// Example: serializing the frame (IWriter is provided by the game's serialization system)
frame.Serialize(writer);

// Example: deserializing
var readFrame = new UpdateFrame();
readFrame.Deserialize(reader);

// Example: assigning as a shared component on an entity (Unity ECS)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = entityManager.CreateEntity();
entityManager.AddSharedComponentData(entity, frame);