Skip to content

Game.Prefabs.UIAssetCategoryPrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: UIGroupPrefab

Summary:
Prefab component that represents a UI "asset category" used in the in-game asset browser/menu. Holds a reference to a UIAssetMenuPrefab and, during prefab initialization, links the created entity with a UIAssetCategoryData component that points to the menu entity and registers the category element with the menu. This enables the UI system to know which menu entity corresponds to this category and to add the category element to that menu.


Fields

  • public UIAssetMenuPrefab m_Menu
    Reference to the menu prefab associated with this category. When non-null the prefab system will:
  • add UIAssetCategoryData as a component type required by the prefab,
  • add the menu prefab as a dependency,
  • during LateInitialize, resolve the menu prefab to an entity, set UIAssetCategoryData on the category entity pointing at that menu entity, and register the category element with the menu via m_Menu.AddElement(...).

Properties

  • This class does not declare any properties.

Constructors

  • public UIAssetCategoryPrefab()
    Default prefab class constructor (implicit). Instances are typically created/filled in the Unity editor as part of a prefab asset.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds component types required by this prefab. Calls base implementation, and if m_Menu is not null, adds ComponentType.ReadWrite() so the entity created from this prefab will have UIAssetCategoryData.

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Collects prefab dependencies. Calls base implementation and, if m_Menu is not null, adds m_Menu to the provided prefabs list so the menu prefab is processed/available before or alongside this category.

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Finalizes entity initialization after prefab conversion. Calls base implementation, then:

  • obtains the Entity corresponding to m_Menu via PrefabSystem.GetEntity(m_Menu),
  • sets UIAssetCategoryData on the category entity with that menu entity reference,
  • calls m_Menu.AddElement(entityManager, entity) to register this category element with the menu.

Notes: - Relies on PrefabSystem to resolve a PrefabBase (m_Menu) to an Entity. - Requires UIAssetCategoryData and UIAssetMenuPrefab types; these must exist in the project. - Behaviour is conditional on m_Menu being non-null — if m_Menu is null, no category-data is added and no menu dependency/registration occurs.

Usage Example

// After prefab conversion and initialization, you can retrieve the menu entity from the category entity:
var prefabSystem = entityManager.World.GetExistingSystemManaged<PrefabSystem>();
Entity categoryEntity = prefabSystem.GetEntity(myCategoryPrefab); // myCategoryPrefab is a UIAssetCategoryPrefab
UIAssetCategoryData data = entityManager.GetComponentData<UIAssetCategoryData>(categoryEntity);
Entity menuEntity = data.menuEntity; // the entity for the UIAssetMenuPrefab assigned to m_Menu

// Alternatively, during authoring in the editor, assign a UIAssetMenuPrefab to m_Menu.
// The prefab system will do the rest during GetDependencies / LateInitialize.