Game.Prefabs.WaterSourceColorElement
Assembly:
Unknown (project assembly containing Game.Prefabs)
Namespace:
Game.Prefabs
Type:
struct
Base:
Unity.Entities.IBufferElementData
Summary:
Represents a buffer element used to store color information for a water source prefab. The element holds separate outline and fill colors for both the regular and projected (preview) states. Marked with InternalBufferCapacity(4) to store up to four elements in-entity before additional allocation occurs. This is intended for use with Unity's DOTS/ECS DynamicBuffer for per-entity collections of color variants (e.g., multiple LODs, layers, or variations).
Fields
-
public Color m_Outline
Outline color used for the normal (non-projected) rendering of the water source. -
public Color m_Fill
Fill color used for the normal (non-projected) rendering of the water source. -
public Color m_ProjectedOutline
Outline color used when the water source is shown in a projected/preview state (e.g., placement preview). -
public Color m_ProjectedFill
Fill color used when the water source is shown in a projected/preview state.
Properties
- None. This type is a plain data struct (IBufferElementData) exposing four public Color fields.
Constructors
public WaterSourceColorElement()
No explicit constructor is defined in the source. The default parameterless struct constructor is available.
Methods
- None. This type only holds data and does not define methods.
Usage Example
// Example: create a buffer on an entity and populate it with colors.
using Unity.Entities;
using UnityEngine;
using Game.Prefabs;
public static class WaterSourceColorExample
{
public static void AddColors(EntityManager entityManager, Entity entity)
{
// Ensure the entity has a DynamicBuffer for WaterSourceColorElement
if (!entityManager.HasComponent<WaterSourceColorElement>(entity))
{
entityManager.AddBuffer<WaterSourceColorElement>(entity);
}
var buffer = entityManager.GetBuffer<WaterSourceColorElement>(entity);
// Clear existing entries and add defaults
buffer.Clear();
buffer.Add(new WaterSourceColorElement
{
m_Outline = Color.cyan,
m_Fill = new Color(0f, 0.5f, 1f, 0.6f),
m_ProjectedOutline = Color.white,
m_ProjectedFill = new Color(1f, 1f, 1f, 0.25f)
});
// You can add up to 4 elements without extra heap allocation because of InternalBufferCapacity(4).
// Adding more will expand the buffer dynamically.
}
}
Notes:
- InternalBufferCapacity(4) means the first 4 elements are stored inline on the entity (better cache locality). Adding more elements will allocate additional memory.
- UnityEngine.Color is used for color values — store RGBA float components.
- Being an IBufferElementData makes this suitable for use in jobs and systems that access DynamicBuffer