Skip to content

Game.EditorContainer

Assembly: Game
Namespace: Game.Tools

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
EditorContainer is an ECS component used by editor/tools code to represent a container entry pointing to a prefab with display/placement metadata. It stores a prefab Entity reference, a scale vector, a numeric intensity value and a group index. The struct implements custom binary serialization (ISerializable) and honors stream versioning when deserializing the group index (older versions will get a default of -1).


Fields

  • public Unity.Entities.Entity m_Prefab
    Holds the Entity reference to the prefab used by this editor container entry. Serialized first in the writer.

  • public Unity.Mathematics.float3 m_Scale
    A float3 describing the scale applied to the prefab for editor presentation. Serialized second.

  • public float m_Intensity
    A float describing intensity (used for visual weighting/preview/etc.). Serialized third.

  • public int m_GroupIndex
    An integer grouping index for the container. When deserializing, this field is only read if the reader context version is at least Version.editorContainerGroupIndex; otherwise it is set to -1.

Properties

  • None.

Constructors

  • public EditorContainer()
    Implicit default constructor for the value type. All fields default to their CLR defaults (Entity = default, m_Scale = (0,0,0), m_Intensity = 0f, m_GroupIndex = 0). Note: deserialization logic sets m_GroupIndex to -1 for older versions, see Deserialize.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component state to writer in this order: m_Prefab, m_Scale, m_Intensity, m_GroupIndex. The method expects the writer to support writing these value types.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the component state from reader using ref locals to fill fields. Reads m_Prefab, m_Scale and m_Intensity unconditionally. For m_GroupIndex it checks the reader.context.version and only reads the group index if reader.context.version >= Version.editorContainerGroupIndex; otherwise it sets m_GroupIndex = -1 to preserve backward compatibility.

Usage Example

// Create and add an EditorContainer component to an entity in an ECS world
var container = new EditorContainer {
    m_Prefab = prefabEntity,
    m_Scale = new float3(1f, 1f, 1f),
    m_Intensity = 0.8f,
    m_GroupIndex = 2
};

entityManager.AddComponentData(entity, container);

// During load/save, the Serialize/Deserialize methods above are used by the game's
// serialization system (IWriter/IReader) and will handle versioning for m_GroupIndex.