Game.Prefabs.TutorialListPrefab
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
Prefab component that represents a list of tutorials. It exposes a priority and an array of TutorialPrefab references. During prefab initialization it registers required ECS component types (TutorialListData and TutorialRef), writes the list priority to the entity's TutorialListData, and populates a DynamicBuffer
Fields
-
public int m_Priority
Priority value assigned to the TutorialListData component on the resulting entity. Typically used by the tutorial system to determine ordering or importance of this tutorial list. -
public TutorialPrefab[] m_Tutorials
Array of TutorialPrefab references that belong to this list. Marked with [NotNull] — should not be null. Each referenced TutorialPrefab will be added to prefab dependencies and later resolved to an Entity and stored in the TutorialRef buffer during LateInitialize.
Properties
- None declared on this class. (All behavior is performed via overridden methods from PrefabBase and data fields.)
Constructors
public TutorialListPrefab()
Default constructor (inherited/implicit). Initialization of fields typically happens in the inspector/prefab asset, not via code.
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds every TutorialPrefab referenced in m_Tutorials to the provided prefabs dependency list. This ensures referenced tutorial prefabs are loaded/resolved before this prefab is initialized. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds required ECS component types for the prefab: TutorialListData (ReadWrite) and TutorialRef (ReadWrite). This declares the components that the resulting entity will contain. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called during prefab initialization. Writes a new TutorialListData with m_Priority into the entity using entityManager.SetComponentData. This stores the priority on the entity. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Resolves each TutorialPrefab in m_Tutorials to an Entity via the game's PrefabSystem (obtained from World.DefaultGameObjectInjectionWorld), and appends a TutorialRef (with m_Tutorial set to that entity) to the entity's DynamicBuffer. This populates the runtime list of tutorial entity references used by systems.
Notes / implementation details: - The method expects PrefabSystem to be available in the DefaultGameObjectInjectionWorld. If PrefabSystem is missing, a NullReference may occur. - The class relies on EntityManager and ECS buffers to store tutorial references rather than storing direct object references at runtime. - m_Tutorials elements should be valid TutorialPrefab assets; otherwise the resolved entity may be invalid.
Usage Example
// After the prefab system has initialized this prefab, you can query the entity to inspect results:
// entityManager and entity are provided by the prefab system once the prefab is instantiated
TutorialListData listData = entityManager.GetComponentData<TutorialListData>(entity);
Debug.Log("Tutorial list priority: " + listData.m_Priority);
DynamicBuffer<TutorialRef> buffer = entityManager.GetBuffer<TutorialRef>(entity);
for (int i = 0; i < buffer.Length; i++)
{
Entity tutorialEntity = buffer[i].m_Tutorial;
// Use tutorialEntity (e.g., read its components) or pass to tutorial systems
}
Additional tips: - In the Unity editor, assign m_Tutorials and set m_Priority on the TutorialListPrefab asset. The prefab system will handle calling Initialize and LateInitialize at the appropriate times. - Ensure referenced TutorialPrefab assets are valid and present in project build; GetDependencies will add them to the prefab dependency graph so they are included.