Game.Prefabs.EffectColorData
Assembly:
Assembly-CSharp
Namespace: Game.Prefabs
Type:
public struct EffectColorData
Base:
System.ValueType
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
Component used to describe a color and per-component variation ranges for an effect prefab/entity. Stores a base Color, a source enum value indicating how the color is chosen (EffectColorSource, defined elsewhere in the codebase), and a float3 containing variation ranges that can be used to randomize or vary the base color when the effect is spawned or updated. Note: the field name m_VaritationRanges contains a typographical spelling ("Varitation") present in the original code.
Fields
-
public UnityEngine.Color m_Color
Base color for the effect. Typically an RGBA Unity Color. Systems reading this component will use this as the starting color before applying any variation. -
public EffectColorSource m_Source
Enum value indicating how the color should be determined/applied (e.g., Fixed, Random, FromPrefab, etc.). The EffectColorSource enum is not declared here — refer to its definition elsewhere in the codebase for possible values and semantics. -
public Unity.Mathematics.float3 m_VaritationRanges
Per-component variation ranges (x, y, z). Intended to be used to vary the color when spawning or updating an effect. Each component is a float that represents the allowed variation for the corresponding color channel (convention depends on the consuming system; often these are used as +/- ranges applied to RGB channels). Note the field name uses "Varitation" (likely intended to be "Variation").
Properties
- None. This struct only exposes public fields (no C# properties).
Constructors
public EffectColorData()
Struct has the default parameterless constructor behavior (fields are default-initialized). You can also initialize explicitly using an object initializer: new EffectColorData { m_Color = Color.white, m_Source = / some enum value /, m_VaritationRanges = new float3(0f) }
Methods
- None. This is a plain data component; logic is expected to be implemented by systems that read or write this component.
Usage Example
Basic examples showing how to add this component to an entity and how a system might read and apply the variation:
// Adding the component to an entity (e.g., when creating a prefab entity)
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = em.CreateEntity();
em.AddComponentData(e, new EffectColorData {
m_Color = Color.cyan,
m_Source = /* set appropriate EffectColorSource enum value */,
m_VaritationRanges = new float3(0.05f, 0.05f, 0.05f)
});
// Example system-like usage (pseudo-code showing the idea)
public partial struct ApplyEffectColorSystem : ISystem
{
public void OnUpdate(ref SystemState state)
{
// Example using SystemAPI-style query to read EffectColorData
foreach (var (colorData, entity) in SystemAPI.Query<RefRO<EffectColorData>>().WithEntityAccess())
{
var baseColor = colorData.ValueRO.m_Color;
var ranges = colorData.ValueRO.m_VaritationRanges;
// Simple randomization example: vary each RGB channel by [-range, +range]
float3 rnd = new float3(
UnityEngine.Random.Range(-ranges.x, ranges.x),
UnityEngine.Random.Range(-ranges.y, ranges.y),
UnityEngine.Random.Range(-ranges.z, ranges.z)
);
Color randomized = new Color(
Mathf.Clamp01(baseColor.r + rnd.x),
Mathf.Clamp01(baseColor.g + rnd.y),
Mathf.Clamp01(baseColor.b + rnd.z),
baseColor.a
);
// Apply 'randomized' to the effect's renderer/material or another component
// (actual application depends on the project's rendering pipeline and component setup)
}
}
}
Notes: - Because EffectColorData implements IComponentData, it is intended for use in Unity's ECS (DOTS) workflows. - Because it also implements IQueryTypeParameter, it can be used directly in certain query APIs; consult local codebase patterns for how queries are written in this project. - The exact semantics of m_VaritationRanges (which channels they map to, clamping rules, and whether alpha is affected) depend on the systems consuming this component — inspect those systems for the definitive behavior.