Skip to content

Game.Prefabs.InfoviewPrefab

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

Type: class

Base: PrefabBase

Summary:
InfoviewPrefab defines a prefab used to represent an "infoview" (a collection or grouping of information modes) in the game. It groups one or more InfomodeInfo entries and provides visual defaults (colors, icon path), ordering (priority and group), and warning categories. During initialization it registers required ECS components (InfoviewData and InfoviewMode) and builds a notification mask from the configured warning categories. The prefab exposes an isValid property that indicates whether the prefab contains at least one InfomodeInfo.


Fields

  • public InfomodeInfo[] m_Infomodes
    Holds the list of InfomodeInfo entries that belong to this infoview. Each entry typically references a mode prefab (m_Mode) that will be added to the prefab dependency list.

  • public Color m_DefaultColor = new Color(0.7f, 0.7f, 0.7f, 1f)
    Default primary color used by the infoview visuals when shown.

  • public Color m_SecondaryColor = new Color(0.6f, 0.6f, 0.6f, 1f)
    Secondary/default accent color used by the infoview visuals.

  • [FormerlySerializedAs("m_IconName")] public string m_IconPath
    Path to the icon asset used by the infoview. Note: previously serialized under the name "m_IconName" — the attribute preserves compatibility with older serialized data.

  • public int m_Priority
    Priority value used to order or sort infoviews in UI lists.

  • public int m_Group
    Group identifier used to group infoviews (for grouping or categorization in UI).

  • public IconCategory[] m_WarningCategories
    Array of warning categories that will be combined into a bitmask and stored in InfoviewData.m_NotificationMask. Used to control which notifications/warnings the infoview should listen for or display.

  • public bool m_Editor
    Flag indicating editor-only behavior (typically set in the inspector for editor-specific infoviews).

  • public bool isValid { get; private set; }
    Property backed by a private setter. True after Initialize if m_Infomodes is non-null and contains at least one entry.

Properties

  • public override bool ignoreUnlockDependencies { get; }
    This override returns true; this prefab ignores unlock dependencies in the prefab dependency/resolution system (i.e., it will not enforce unlock-based dependencies).

  • public bool isValid { get; private set; }
    Indicates whether this InfoviewPrefab is considered valid (m_Infomodes != null && m_Infomodes.Length != 0). Set during Initialize.

Constructors

  • public InfoviewPrefab()
    Default parameterless constructor (implicit). No custom construction logic present in the class — fields get their default/serialized values.

Methods

  • public override void GetDependencies(System.Collections.Generic.List<PrefabBase> prefabs)
    Adds referenced prefabs to the provided list so the prefab system knows about dependencies. Implementation:
  • Calls base.GetDependencies(prefabs).
  • If m_Infomodes is not null, iterates them and adds each m_Infomodes[i].m_Mode to the prefabs list (each InfomodeInfo is expected to reference a PrefabBase in its m_Mode field).

  • public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
    Adds required ECS component types for entities created from this prefab. Implementation:

  • Calls base.GetPrefabComponents(components).
  • Adds ComponentType.ReadWrite().
  • Adds ComponentType.ReadWrite().

  • public override void Initialize(Unity.Entities.EntityManager entityManager, Unity.Entities.Entity entity)
    Initializes entity component data for an entity instantiated from this prefab. Implementation:

  • Calls base.Initialize(entityManager, entity).
  • Constructs an InfoviewData struct and initializes m_NotificationMask to 0.
  • If m_WarningCategories is non-null, iterates them and ORs bits into m_NotificationMask: componentData.m_NotificationMask |= (uint)(1 << (int)category).
  • Writes the InfoviewData to the entity via entityManager.SetComponentData(entity, componentData).
  • Sets isValid to true when m_Infomodes is non-null and length > 0; otherwise false.

Notes: - The notification mask is built by shifting 1 by the IconCategory enum value; ensure IconCategory enum values are appropriate and within bit-range. - The class uses Unity serialization attributes (FormerlySerializedAs) and is exposed to Unity's component/menu systems via ComponentMenu.

Usage Example

// Example: initialize an entity from an InfoviewPrefab and read the notification mask
// (This code runs in a context where prefab instance and Worlds are available)

InfoviewPrefab infoviewPrefab = /* obtain reference from prefab manager or inspector */;
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = em.CreateEntity(); // in real setup you would create with required archetype/components

// Initialize the entity with prefab data (this will set InfoviewData and InfoviewMode components)
infoviewPrefab.Initialize(em, e);

// Read the notification mask set by Initialize
InfoviewData data = em.GetComponentData<InfoviewData>(e);
Debug.Log($"Infoview notification mask: {data.m_NotificationMask}");

// Check whether the prefab is considered valid (has at least one Infomode)
if (infoviewPrefab.isValid)
{
    Debug.Log("InfoviewPrefab is valid and contains Infomodes.");
}
else
{
    Debug.LogWarning("InfoviewPrefab is invalid: no Infomodes configured.");
}

Additional implementation notes: - Ensure m_Infomodes entries are configured in the inspector; otherwise isValid will be false and the infoview will be considered empty. - The prefab registers InfoviewData and InfoviewMode component types — corresponding ECS struct definitions must exist for runtime usage.