Skip to content

Game.Prefabs.BuildingInfomodePrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ColorInfomodeBasePrefab

Summary:
Prefab component class used to configure a building infomode entry for the game's infomode UI. This prefab associates a specific BuildingType with the infoview data used by the infomode system and registers the runtime component type (InfoviewBuildingData) with the entity. The class is decorated with a ComponentMenu attribute so it appears under Tools/Infomode/ in the editor.


Fields

  • public BuildingType m_Type
    Holds the BuildingType value that this prefab will write into the entity's InfoviewBuildingData when initialized. This determines which subset/category of buildings this infomode entry targets.

Properties

  • public override string infomodeTypeLocaleKey { get; }
    Returns the localization key for this infomode type. For BuildingInfomodePrefab it returns "BuildingColor", which is used to look up the localized display name for this infomode in the UI.

Constructors

  • public BuildingInfomodePrefab()
    Implicit default constructor. No custom construction logic is defined in the source file; initialization is handled in the Initialize method at entity creation time.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the runtime component types that should be present on entities created from this prefab. This override calls the base implementation and then adds ComponentType.ReadWrite<InfoviewBuildingData>() so the entity receives the InfoviewBuildingData component.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab is instantiated into an Entity. This override calls the base Initialize and then sets the InfoviewBuildingData component on the entity using the prefab's m_Type field:

  • Uses entityManager.SetComponentData(entity, new InfoviewBuildingData { m_Type = m_Type });
  • Requires Unity.Entities.EntityManager and the InfoviewBuildingData struct to be defined elsewhere in the project.

Usage Example

// Example of what the prefab's Initialize does when the prefab is converted to an entity.
public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);
    // Ensure the InfoviewBuildingData component receives the prefab's building type
    entityManager.SetComponentData(entity, new InfoviewBuildingData
    {
        m_Type = m_Type
    });
}

Additional notes: - Requires Unity.Entities and the InfoviewBuildingData component/struct and BuildingType enum to be present in the project. - The ComponentMenu attribute places this prefab under Tools/Infomode/ in the editor for easier authoring.