Skip to content

Game.Prefabs.ThemePrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
Represents a theme prefab used by the game. Exposes an assetPrefix string (used to identify or group theme-related assets) and overrides GetPrefabComponents to ensure the ThemeData ECS component is included on the prefab. The class is marked with a Unity ComponentMenu attribute so it appears under the "Themes/" menu in the Unity editor.


Fields

  • public string assetPrefix
    A string prefix used to identify or group assets belonging to this theme. Typically set in the Unity inspector or when creating the prefab in code. If not set, it will be null/empty.

Properties

  • This class has no public properties.

Constructors

  • public ThemePrefab()
    Default parameterless constructor (Unity/MonoBehaviour/ScriptableObject style instantiation). No custom construction logic is defined in the class.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Populates the provided set of Unity.Entities.ComponentType entries for this prefab. The method calls the base implementation and then adds a read/write ThemeData component (ComponentType.ReadWrite()) so that the ECS world knows prefabs of this type require ThemeData.

Additional notes: - The method expects a HashSet from Unity.Entities and modifies it in place. - Ensures that the ThemeData component will be present/required when the prefab is converted/used by the ECS systems.

Usage Example

// Create and configure a ThemePrefab in code (or set assetPrefix in the inspector)
var prefab = ScriptableObject.CreateInstance<Game.Prefabs.ThemePrefab>();
prefab.assetPrefix = "modern_";

// Collect component types for this prefab
var components = new HashSet<Unity.Entities.ComponentType>();
prefab.GetPrefabComponents(components);

// After calling, components will include ComponentType.ReadWrite<ThemeData>()