Game.Prefabs.ForceUIGroupUnlock
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Component attached to prefab GameObjects that forces one or more UIGroupPrefabs to become unlocked whenever this prefab itself unlocks. This happens regardless of the UI groups' own unlock requirements. The component requires an UnlockableBase on the same GameObject and is exposed in the editor under the "Prefabs/Unlocking/" Component Menu (used by tutorial-related prefabs).
Fields
public UIGroupPrefab[] m_Unlocks
Array of UIGroupPrefabs that will be forced unlocked when this prefab unlocks. Each entry is translated to an entity reference and stored in the prefab's ForceUIGroupUnlockData buffer during LateInitialize.
Properties
- None declared.
Constructors
public ForceUIGroupUnlock()
Default constructor (inherited behavior from ComponentBase). No custom initialization logic in the source.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the required ECS component type(s) for this prefab to the supplied set. Implementation adds a read/write ForceUIGroupUnlockData component so the prefab will have a DynamicBufferat entity creation. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Override provided but does not add any archetype components in this implementation (empty body). Kept for compatibility with the prefab/component pipeline. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Called late in prefab->entity conversion. Resolves each UIGroupPrefab in m_Unlocks to an Entity via the PrefabSystem and appends a ForceUIGroupUnlockData entry (with m_Entity set) to the entity's DynamicBuffer. Requires PrefabSystem to be present in the world; if UIGroupPrefabs are null or entries are missing, behavior depends on PrefabSystem.GetEntity implementation (typically returns Entity.Null or throws — check PrefabSystem behavior).
Remarks:
- This method relies on the world containing a PrefabSystem (retrieved via entityManager.World.GetExistingSystemManaged
Usage Example
// Example: attach ForceUIGroupUnlock to a prefab (usually done in the editor).
// In code you can assign the UIGroupPrefabs at runtime (or via inspector in prefabs):
public class ExampleAssign : MonoBehaviour
{
public ForceUIGroupUnlock forceUnlock;
public UIGroupPrefab myUiGroup; // assign via inspector
void Awake()
{
if (forceUnlock != null)
{
forceUnlock.m_Unlocks = new UIGroupPrefab[] { myUiGroup };
}
}
}
Additional notes: - Ensure the GameObject also has an UnlockableBase component (the class has a RequireComponent attribute for UnlockableBase). - The actual unlocking behavior is implemented elsewhere: this component only prepares the ForceUIGroupUnlockData buffer so runtime systems can perform the unlock when the prefab unlock event occurs.