Skip to content

Game.Prefabs.AssetPackPrefab

Assembly:
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
A prefab helper MonoBehaviour used to mark a prefab as containing an AssetPackData component for the ECS world. This class is annotated with Unity's ComponentMenu attribute so it appears in the editor menu under "Prefabs/Asset Packs/". Its main purpose is to contribute the AssetPackData component type to the set of component types created for the prefab when converted/processed by the game's prefab-to-entity logic. It calls the base implementation then adds ComponentType.ReadWrite() to the supplied component set.


Fields

  • None
    This class declares no instance or static fields.

Properties

  • None
    No properties are declared on this class.

Constructors

  • public AssetPackPrefab()
    The class uses the default parameterless constructor (compiler-generated). No custom construction logic is provided.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Overrides PrefabBase.GetPrefabComponents to add the AssetPackData component type to the provided set. Implementation details:
  • Calls base.GetPrefabComponents(components) to preserve any base behavior.
  • Calls components.Add(ComponentType.ReadWrite()) to ensure the prefab will include a read/write AssetPackData component in the ECS representation.

Additional notes: - ComponentType.ReadWrite() marks the component as read/write for the ECS entity archetype created from the prefab. - AssetPackData must be a component type known to the ECS (IComponentData or similar) for this to be meaningful. - This class itself is a Unity component (MonoBehaviour-derived via PrefabBase) and is intended to be placed on Unity prefab GameObjects so conversion code can detect and include the corresponding ECS component.

Usage Example

// Example: When the prefab conversion/registration runs, the system will call:
var components = new HashSet<ComponentType>();
var assetPackPrefab = gameObject.GetComponent<Game.Prefabs.AssetPackPrefab>();
assetPackPrefab.GetPrefabComponents(components);

// After the call, 'components' will include:
// ComponentType.ReadWrite<AssetPackData>()

{{ This prefab class should be added to a GameObject prefab in the Unity editor (or created via code) to ensure the resulting ECS entity created from that prefab contains an AssetPackData component. The ComponentMenu attribute makes it easy to add this component from the "Add Component" menu under "Prefabs/Asset Packs/". }}