Game.Rendering.MeshColor
Assembly: Assembly-CSharp (game assembly, may vary)
Namespace: Game.Rendering
Type: struct
Base: IBufferElementData, IEmptySerializable
Summary:
MeshColor is a lightweight ECS buffer element that stores colour information for a mesh via a ColorSet field. It is marked with InternalBufferCapacity(1), indicating the entity buffer will be preallocated with a capacity of 1 element by default. This struct is intended for use with Unity.Entities (DOTS) systems to attach per-entity/per-mesh color data that the rendering pipeline or custom rendering systems can consume. The IEmptySerializable interface and the Colossal attribute indicate the struct participates in the game's custom serialization pipeline.
Fields
-
public ColorSet m_ColorSet
Holds the color data for the mesh. The concrete definition of ColorSet is not included in this file; it is expected to be a struct (or type) that contains the color channels or palettes used by the rendering/mod systems. This field is the payload stored in the entity buffer element. -
InternalBufferCapacity(1)
(attribute applied to the struct)
Specifies that DynamicBuffers of this element type will be optimized for small size by reserving a capacity of 1 element inline before allocating additional memory. Useful when most entities will only need a single MeshColor entry.
Properties
- (none)
This struct exposes no properties; it only contains a public field.
Constructors
- (implicit)
public MeshColor()
As a value type (struct), MeshColor has an implicit parameterless constructor that initializes fields to their default values. No explicit constructors are defined in the source.
Methods
- (none)
No methods are defined on this struct.
Notes
- IBufferElementData: Use this type with DynamicBuffer
on entities. Typical access is via EntityManager.GetBuffer (entity) or in a SystemBase via EntityQuery/ForEach with DynamicBuffer . - IEmptySerializable and Colossal.Serialization.Entities: These markers relate to the game's serialization system and indicate the struct is serializable by the game's custom serializer.
- Because MeshColor is a struct and contains other value-type fields, be mindful of copying cost; keep the contained ColorSet as small and blittable as practical for performance.
Usage Example
// Add a MeshColor buffer to an entity and set its ColorSet.
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = entityManager.CreateEntity();
// Add the DynamicBuffer container for MeshColor
var buffer = entityManager.AddBuffer<Game.Rendering.MeshColor>(entity);
// Populate the buffer with one MeshColor entry.
// Replace ColorSet(...) with the actual constructor or assignment appropriate for your ColorSet type.
buffer.Add(new Game.Rendering.MeshColor {
m_ColorSet = new ColorSet(/* ... initialize color(s) ... */)
});
// In a system, read the buffer:
Entities.ForEach((Entity e, DynamicBuffer<Game.Rendering.MeshColor> colors) =>
{
if (colors.Length > 0)
{
var cs = colors[0].m_ColorSet;
// use cs in rendering/update logic
}
}).WithoutBurst().Run();