Skip to content

Game.Prefabs.UIProductionLinkPrefab

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

Type: class

Base: PrefabBase

Summary:
UIProductionLinkPrefab is a prefab descriptor used by the UI/prodution system to mark a prefab with the UIProductionLinkData component and to hold simple configuration used when building UI production-link entities (for example: which production-chain actor type the link represents and which icon to use). It also exposes a Unity editor menu entry via the ComponentMenu attribute.


Fields

  • public ProductionChainActorType m_Type
    This field indicates the type of production-chain actor this UI link represents (the specific enum values are defined by ProductionChainActorType elsewhere in the codebase). The value is used by systems that build or render UI production links to determine behavior or visuals.

  • public string m_Icon
    A string identifier for the icon to display for this production link in the UI. Typically this is a resource name or path that the UI code resolves to a sprite/texture.

Properties

This class does not declare any properties of its own. It only exposes public fields and overrides GetPrefabComponents from its base class.

Constructors

  • public UIProductionLinkPrefab()
    The implicit default constructor is used. Initialization logic (if any) is inherited from PrefabBase. No additional construction-time work is performed by this class.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    When called, this method first invokes the base implementation (PrefabBase.GetPrefabComponents) and then adds ComponentType.ReadWrite() to the provided set. This ensures that entities created from this prefab will include a UIProductionLinkData component (read/write). The method uses Unity.Entities.ComponentType and the ReadWrite generic to declare the required component.

Notes: - The class is annotated with [ComponentMenu("UI/", new Type[] { })], which places it under the "UI" menu in the Unity component/prefab creation UI (editor convenience). - UIProductionLinkData is the component type added to prefab entities; its structure and fields are defined elsewhere and should be populated after entity creation as appropriate.

Usage Example

// Create/configure the prefab instance in code (or this could be set up in editor)
var prefab = new UIProductionLinkPrefab {
    m_Type = ProductionChainActorType.Producer, // example enum value
    m_Icon = "Icons/production_link"
};

// Gather the component types the prefab requires
var components = new HashSet<ComponentType>();
prefab.GetPrefabComponents(components);

// Create an entity archetype from those components (example using EntityManager)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(new List<ComponentType>(components).ToArray());
var entity = entityManager.CreateEntity(archetype);

// After creating the entity, populate the UIProductionLinkData component as needed:
// entityManager.SetComponentData(entity, new UIProductionLinkData { /* ... */ });

Additional tips: - Ensure the UIProductionLinkData component is filled with the correct runtime data after creating the entity (its fields are defined elsewhere). - m_Icon should match whatever asset lookup your UI system expects (sprite name, resource key, etc.).