Game.Prefabs.TutorialZoningTriggerPrefab
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: public class
Base: TutorialTriggerPrefabBase
Summary:
Prefab class used by the tutorial system to create zoning-related tutorial triggers. Holds references to one or more ZonePrefab assets and:
- declares a dependency on those zone prefabs so they are loaded,
- registers the ZoningTriggerData component for the prefab,
- populates a DynamicBuffer
Fields
public ZonePrefab[] m_Zones
Array of zone prefabs referenced by this tutorial trigger. Marked [NotNull] in the source, expected to be set in the prefab (Inspector). Each referenced ZonePrefab is added to dependency lists and converted to an Entity reference during LateInitialize.
Properties
- None specific to this class. All exposed behavior is via methods and the public m_Zones field.
Constructors
public TutorialZoningTriggerPrefab()
Implicit default constructor. This is a prefab/MonoBehaviour-style class and instances are normally created/managed by the prefab system and Unity editor rather than constructed directly in user code.
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds each non-null ZonePrefab referenced in m_Zones to the provided prefabs list (after calling base implementation). Ensures the zone prefabs are considered dependencies of this tutorial trigger prefab. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the component typeZoningTriggerData
(read-write) to the hash set after calling base implementation. This causes the prefab to include/register a DynamicBufferon the resulting entity. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Called when the prefab is converted to an entity. Calls base.LateInitialize, retrieves the DynamicBufferfrom the created entity, and fills it with ZoningTriggerData entries obtained from the PrefabSystem for each ZonePrefab in m_Zones: - Uses
entityManager.World.GetExistingSystemManaged<PrefabSystem>()
to get PrefabSystem. -
For each zonePrefab, calls
existingSystemManaged.GetEntity(zonePrefab)
and adds new ZoningTriggerData(entity) to the buffer. -
protected override void GenerateBlinkTags()
Generates blink/tag positions for in-game UI highlighting related to each zone prefab: - Iterates m_Zones and, if the ZonePrefab has a UIObject component and that object's group is a UIAssetCategoryPrefab with a non-null m_Menu, calls
AddBlinkTagAtPosition
with:- zonePrefab.uiTag (position 0),
- uIAssetCategoryPrefab.uiTag (position 1),
- uIAssetCategoryPrefab.m_Menu.uiTag (position 2).
-
Calls base.GenerateBlinkTags() first.
-
public override void GenerateTutorialLinks(EntityManager entityManager, NativeParallelHashSet<Entity> linkedPrefabs)
Adds the entity for each ZonePrefab (obtained via PrefabSystem) to the provided linkedPrefabs set after calling base implementation. This registers the zone prefab entities as linked prefabs for tutorial navigation/flow.
Usage Example
// This shows how the prefab's LateInitialize creates ZoningTriggerData entries
// for each referenced ZonePrefab and how you can access that buffer afterwards.
public void InspectTutorialTrigger(EntityManager entityManager, Entity tutorialEntity)
{
// After the prefab conversion / LateInitialize runs, the entity will have a buffer:
if (entityManager.HasBuffer<ZoningTriggerData>(tutorialEntity))
{
DynamicBuffer<ZoningTriggerData> buffer = entityManager.GetBuffer<ZoningTriggerData>(tutorialEntity);
foreach (var zoningData in buffer)
{
Entity zoneEntity = zoningData.ZonePrefabEntity; // ZoningTriggerData holds the referenced zone entity
// Use zoneEntity for further setup or inspection...
}
}
}
Notes: - This class is intended to be used as a prefab asset in the editor; m_Zones is typically assigned via the Inspector. - It relies on PrefabSystem to translate ZonePrefab assets into Entities during conversion/initialization.