Skip to content

Game.Prefabs.ObjectSubObjects

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
Component used on object prefabs to declare and expose sub-object references (ObjectSubObjectInfo entries). This component informs the prefab dependency system about which other prefabs are used as sub-objects and ensures that the entity archetype includes the SubObject component required by those sub-objects. It overrides dependency and component-collection methods from ComponentBase to integrate with the game's prefab / ECS conversion pipeline.


Fields

  • public ObjectSubObjectInfo[] m_SubObjects
    Array of ObjectSubObjectInfo describing each sub-object attached to the parent object. Each entry typically references another PrefabBase (via m_Object). Used by GetDependencies to add referenced prefabs to the dependency list so they are loaded/processed together.

Properties

  • public override bool ignoreUnlockDependencies => true
    Overrides the base property to indicate this component should bypass unlock-dependency checks. This means sub-object references won't be blocked by unlock requirements when collecting dependencies for the prefab.

Constructors

  • public ObjectSubObjects()
    No explicit constructor is defined in the source; the class uses the default parameterless constructor provided by C#. Initialization of m_SubObjects should be done via the inspector or by code before use.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Calls base.GetDependencies(prefabs) then iterates over m_SubObjects and adds each referenced prefab (m_SubObjects[i].m_Object) to the provided prefabs list. This ensures that any prefabs used as sub-objects are included in the dependency graph for loading and prefab processing.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds ComponentType.ReadWrite() to the given set of component types. This declares that entities created for this prefab should include a SubObject component at runtime.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds ComponentType.ReadWrite() (fully-qualified type) to the set of archetype components. This ensures the ECS archetype for entities representing this prefab includes the SubObject component so sub-objects have the required data storage.

Usage Example

// Example: programmatically gather dependencies declared by an ObjectSubObjects instance
var objectSub = new Game.Prefabs.ObjectSubObjects();
// m_SubObjects would normally be set in the inspector or by prefab construction code
// objectSub.m_SubObjects = new[] { new ObjectSubObjectInfo { m_Object = somePrefab } };

var dependencies = new List<PrefabBase>();
objectSub.GetDependencies(dependencies);

// dependencies now contains all prefabs referenced by m_SubObjects (in addition to any base dependencies)

Additional notes: - Ensure m_SubObjects is not null before relying on it at runtime (inspectors typically serialize this array). - The component's role is metadata for the prefab -> entity conversion process; it does not itself manage runtime spawning of sub-objects.