Game.Prefabs.Effects.LightIntensity
Assembly: Assembly-CSharp
Namespace: Game.Prefabs.Effects
Type: class
Base: System.Object
Summary:
Serializable container that represents a light intensity value and its unit. Primarily used by effect prefabs to store/configure the intensity of a light. Includes a utility to convert any enum type into an array of UI-friendly EnumMember entries (useful for dropdowns/selectors). The class is annotated for Unity serialization and has backward-compatible serialized name support via FormerlySerializedAs.
Fields
-
public float m_Intensity = 10f
Holds the numeric intensity of the light. Default value is 10. Annotated with [FormerlySerializedAs("m_LuxIntensity, m_Intensity")] for backwards compatibility with older serialized names. -
public LightUnit m_LightUnit = LightUnit.Lux
Specifies the unit used by m_Intensity (type is Game.Rendering.LightUnit). Default is LightUnit.Lux.
Properties
This class does not declare any C# properties. It exposes its data via the public fields above which are Unity-serializable.
Constructors
- Implicit default constructor
public LightIntensity()
No explicit constructors are defined; the default parameterless constructor is provided by the runtime. Instances are typically created and populated by Unity's serialization system when loading prefabs or by code when constructing effect data.
Methods
public static EnumMember[] ConvertToEnumMembers<TEnum>() where TEnum : Enum
Converts all values of the enum type TEnum into an array of EnumMember (Game.UI.Widgets.EnumMember). Each EnumMember contains the enum value as an unsigned 64-bit integer and the enum name as a string. This is useful for creating UI selections (dropdowns, list items) that need both a numeric value and a display string.
Behavior: - Iterates Enum.GetValues(typeof(TEnum)). - For each enum value, creates new EnumMember(Convert.ToUInt64(e), e.ToString()). - Returns the results as an array.
Usage Example
// Create/configure an instance
var light = new LightIntensity();
light.m_Intensity = 25f;
light.m_LightUnit = LightUnit.Lux;
// Convert LightUnit enum into UI EnumMember entries for a dropdown
EnumMember[] members = LightIntensity.ConvertToEnumMembers<LightUnit>();
// Example: populate a UI dropdown (pseudo-code)
myDropdown.SetItems(members.Select(m => m.DisplayName).ToArray());
myDropdown.SetValue(members.First(m => m.Value == (ulong)light.m_LightUnit).Value);
Additional notes: - The class is marked [Serializable] so Unity can serialize it as part of prefabs and scriptable objects. - The ConvertToEnumMembers helper is generic and works with any enum type, not just LightUnit.