Game.Prefabs.CharacterElement
Assembly: Game (Assembly-CSharp)
Namespace: Game.Prefabs
Type: struct
Base: Unity.Entities.IBufferElementData
Summary:
CharacterElement is a buffer element used by the Entities-based character/prefab system to store per-character stylistic and blending data. It holds a reference to a style Entity plus several BlendWeights structs (shape, texture, overlay, mask) and integer indices for animation/pose clip selection. The struct is marked with [InternalBufferCapacity(0)] meaning no elements are stored in-chunk by default (buffer storage is dynamic).
Fields
-
public Unity.Entities.Entity m_Style
Reference to a style Entity (likely a prefab or style descriptor entity) associated with this character element. This Entity can be used to look up style assets, materials, or other style-specific data. -
public Game.Rendering.BlendWeights m_ShapeWeights
Blend weights used for shape (morph targets/geometry) blending. The exact structure/meaning of BlendWeights is defined in Game.Rendering and typically contains per-target weight values. -
public Game.Rendering.BlendWeights m_TextureWeights
Blend weights used for texture blending (e.g., layered/differing texture variants). -
public Game.Rendering.BlendWeights m_OverlayWeights
Blend weights used for overlay layers (decals, makeup, additional overlays). -
public Game.Rendering.BlendWeights m_MaskWeights
Blend weights used for mask-based blending (mask-driven composites). -
public int m_RestPoseClipIndex
Index into a clip/animation table used to choose the rest-pose clip for this character element. -
public int m_CorrectiveClipIndex
Index into a clip/animation table used to choose a corrective clip (used for corrective shape/pose adjustments).
Properties
- (none)
This type does not expose properties; all data members are public fields.
Constructors
- (implicit)
public CharacterElement()
No explicit constructors are declared. The default parameterless struct constructor is used. Initialize fields explicitly when creating instances or when writing into a DynamicBuffer.
Methods
- (none)
This is a plain data container (IBufferElementData) and does not define methods. Behavior and processing are handled by systems that read or write this buffer.
Notes and Remarks
- The [InternalBufferCapacity(0)] attribute indicates the buffer has no in-chunk storage reserved, so elements will be stored in separate heap memory. This is useful for buffers that often contain many elements or whose size is dynamic.
- BlendWeights is defined in Game.Rendering; check that type for details (component count, layout, expected ranges).
- The integer clip indices are likely indexes into a character animation/clip table maintained by another system. Ensure index validity when assigning values.
- Because this is an IBufferElementData, it must be used via DynamicBuffer
(EntityManager.GetBuffer or via Entities.ForEach with buffers) rather than as a single component.
Usage Example
using Unity.Entities;
using Game.Prefabs;
using Game.Rendering;
// Assuming entity is a pre-created entity (e.g., a character entity)
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
// Add a dynamic buffer if not present
if (!em.HasComponent<CharacterElement>(entity))
{
em.AddBuffer<CharacterElement>(entity); // respects InternalBufferCapacity(0)
}
var buffer = em.GetBuffer<CharacterElement>(entity);
// Create and add a CharacterElement
CharacterElement elem = new CharacterElement
{
m_Style = styleEntity, // some Entity reference to a style/prefab
m_ShapeWeights = new BlendWeights(), // initialize as appropriate
m_TextureWeights = new BlendWeights(),
m_OverlayWeights = new BlendWeights(),
m_MaskWeights = new BlendWeights(),
m_RestPoseClipIndex = 0,
m_CorrectiveClipIndex = -1 // -1 if none
};
buffer.Add(elem);