Game.Prefabs.TutorialObjectSelectionActivation
Assembly:
Assembly-CSharp.dll
Namespace:
Game.Prefabs
Type:
class
Base:
TutorialActivation
Summary:
A tutorial activation component used by the game's tutorial system to require or watch for the selection of specific prefabs (game objects). Placed on tutorial prefabs via the ComponentMenu attribute, it populates an ObjectSelectionActivationData buffer for the tutorial entity with references to the target prefab entities and whether the in-game tool is allowed. It also contributes prefab dependencies and generates links from the tutorial to the referenced prefabs.
Fields
-
public PrefabBase[] m_Prefabs
[NotNull] Array of prefab references configured in the inspector. These are the prefabs that the tutorial activation will target. During initialization each PrefabBase is resolved to a runtime Entity via the PrefabSystem so that selection checks can be done against entities. -
public bool m_AllowTool
Flag indicating whether the tool (selection mode) is allowed/enabled for this activation. This value is stored in the ObjectSelectionActivationData entries created during LateInitialize.
Properties
public override bool ignoreUnlockDependencies { get; }
Always returns true (overridden). This tells the tutorial system to ignore unlock dependencies for this activation — the activation should not be gated by normal prefab unlock requirements.
Constructors
public TutorialObjectSelectionActivation()
Default constructor (implicit). Typical usage is to add and configure this component on a Tutorial prefab in the editor; no special runtime construction logic is implemented in this class.
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds the m_Prefabs entries to the provided prefabs list. Calls base.GetDependencies(prefabs) first to preserve any base class dependencies. Use: ensures the tutorial system knows the tutorial depends on the listed prefabs. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Empty override. The class does not add any entity archetype components here. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Calls base.GetPrefabComponents(components) and then adds ComponentType.ReadWrite(). This declares that tutorial prefab entities spawned from this component will include a DynamicBuffer component. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Resolves each PrefabBase in m_Prefabs to an Entity via the PrefabSystem and appends an ObjectSelectionActivationData entry (entity reference + m_AllowTool) into the tutorial entity's DynamicBuffer. This sets up the runtime data the tutorial runtime will use to track required selections. -
public override void GenerateTutorialLinks(EntityManager entityManager, NativeParallelHashSet<Entity> linkedPrefabs)
Adds each referenced prefab entity to linkedPrefabs using PrefabSystem.GetEntity(prefab). This creates tutorial links to the prefabs for dependency/tracking purposes.
Usage Example
// Example: when a custom tutorial prefab is created, this component will be configured in the editor
// with m_Prefabs pointing to one or more PrefabBase assets and m_AllowTool set as needed.
// LateInitialize shows how the runtime buffer is populated:
protected override void LateInitialize(EntityManager entityManager, Entity entity)
{
base.LateInitialize(entityManager, entity);
DynamicBuffer<ObjectSelectionActivationData> buffer = entityManager.GetBuffer<ObjectSelectionActivationData>(entity);
PrefabSystem prefabSystem = entityManager.World.GetExistingSystemManaged<PrefabSystem>();
foreach (PrefabBase prefab in m_Prefabs)
{
if (prefabSystem.TryGetEntity(prefab, out var prefabEntity))
{
buffer.Add(new ObjectSelectionActivationData(prefabEntity, m_AllowTool));
}
}
}
Additional notes: - The component uses PrefabSystem to resolve PrefabBase -> Entity; ensure the PrefabSystem is available in the World when LateInitialize runs. - The ObjectSelectionActivationData type is expected to be defined elsewhere in the tutorial/activation systems and contains at least an Entity reference and the tool-allowed flag. - Configure m_Prefabs in the Unity editor on the Tutorial prefab; failing to assign entries will result in no activation targets being added.