Skip to content

Game.Prefabs.RenderingSettingsPrefab

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
Prefab component that holds rendering-related color settings and writes them into an ECS component (RenderingSettingsData) when the prefab is initialized. Used to centralize colors for various UI / rendering states (hover, override, warning, error, owner) so systems can read a single ECS component for rendering behavior.


Fields

  • public UnityEngine.Color m_HoveredColor
    Color used for hovered/highlighted items. Default: Color(0.5f, 0.5f, 1f, 0.1f). This value is copied into RenderingSettingsData during Initialize so rendering systems can use it at runtime.

  • public UnityEngine.Color m_OverrideColor
    Color used when an override state should be indicated. Default: Color(1f, 1f, 1f, 0.1f).

  • public UnityEngine.Color m_WarningColor
    Color used for warning states. Default: Color(1f, 1f, 0.5f, 0.1f).

  • public UnityEngine.Color m_ErrorColor
    Color used for error states. Default: Color(1f, 0.5f, 0.5f, 0.1f).

  • public UnityEngine.Color m_OwnerColor
    Color used to indicate ownership or similar state. Default: Color(0.5f, 1f, 0.5f, 0.1f).

Properties

  • This class does not define any public properties. The color values are exposed as public fields and are propagated into the RenderingSettingsData ECS component.

Constructors

  • public RenderingSettingsPrefab()
    No explicit constructor is defined in the source; the default constructor is used. Field initializers define the default color values shown above.

Methods

  • public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
    Adds the ECS component type that this prefab provides. Specifically, this method adds ComponentType.ReadWrite() so entities created from this prefab will contain a RenderingSettingsData component.

  • public override void GetArchetypeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
    Currently calls the base implementation only. This method is available to declare additional archetype components required by the prefab; in this implementation no extra components are added beyond the prefab components.

  • public override void Initialize(Unity.Entities.EntityManager entityManager, Unity.Entities.Entity entity)
    Creates a RenderingSettingsData struct populated from the prefab's color fields and writes it to the provided entity via entityManager.SetComponentData(entity, componentData). This is the runtime step that transfers the authoring (prefab) values into ECS component storage for use by rendering systems.

Usage Example

// Example: reading the rendering colors from an entity after prefab initialization
// (Assumes an entity was created from this prefab and Initialize(...) was invoked)

using Unity.Entities;
using UnityEngine;

void UseRenderingSettings(EntityManager entityManager, Entity entity)
{
    if (entityManager.HasComponent<RenderingSettingsData>(entity))
    {
        RenderingSettingsData data = entityManager.GetComponentData<RenderingSettingsData>(entity);
        Color hovered = data.m_HoveredColor;
        // use 'hovered' color for custom rendering logic...
    }
}

// Example: override the prefab defaults in a derived prefab class
public class CustomRenderingSettingsPrefab : RenderingSettingsPrefab
{
    public CustomRenderingSettingsPrefab()
    {
        // change the hovered color before initialization
        m_HoveredColor = new Color(0.8f, 0.2f, 0.2f, 0.15f);
    }

    public override void Initialize(EntityManager entityManager, Entity entity)
    {
        // you can adjust fields here as well, then call base to write them to ECS
        base.Initialize(entityManager, entity);
    }
}