Skip to content

Game.Prefabs.TutorialBalloonPrefab

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: class

Base: TutorialPhasePrefab

Summary:
TutorialBalloonPrefab defines a tutorial "balloon" phase prefab. A balloon phase displays a UI balloon (tooltip) that can point at one or more UI targets. The prefab contains an array of BalloonUITarget entries that specify which UI prefab/tag provides the UI element to attach the balloon to, the balloon's pointing direction, and its alignment. The prefab registers dependencies for those UI providers, initializes the phase data as a balloon phase, and links the prefab entities for runtime usage in the entity world. Additional details: - Contains a nested BalloonUITarget class which is serializable and implements IJsonWritable for saving the target definition in JSON. - Defines two enums: BalloonDirection (up, down, left, right) and BalloonAlignment (start, center, end). - Intended for use in the Cities: Skylines 2 tutorial system to show context-aware helper balloons that point to UI elements.


Fields

  • public BalloonUITarget[] m_UITargets
    An array of targets for the balloon. Each entry specifies the UI provider prefab (m_UITagProvider), the pointer direction (m_BalloonDirection), and alignment (m_BalloonAlignment). Marked [NotNull], so the array itself should not be null.

Nested-type fields (inside BalloonUITarget):

  • public PrefabBase m_UITagProvider
    Reference to a prefab that provides a UI tag used to locate the UI element at runtime. May be null; when present, the prefab is added to dependencies and linked as an entity in GenerateTutorialLinks.

  • public BalloonDirection m_BalloonDirection
    Direction the balloon should point relative to the UI target. Default is BalloonDirection.up.

  • public BalloonAlignment m_BalloonAlignment
    Alignment of the balloon relative to the target. Default is BalloonAlignment.center.


Properties

  • This type does not declare any public properties.

Constructors

  • public TutorialBalloonPrefab()
    Implicit default constructor. Use the prefab via Unity/Prefab workflows; no special construction logic in code.

Nested type constructor:

  • public BalloonUITarget()
    Initializes a BalloonUITarget with default values:
  • m_BalloonDirection = BalloonDirection.up
  • m_BalloonAlignment = BalloonAlignment.center

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds dependent prefabs required by this template to the provided list. For each BalloonUITarget with a non-null m_UITagProvider, that provider prefab is added to the prefabs list. Call base.GetDependencies(prefabs) to preserve base behavior.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Initializes the entity for this tutorial phase. Sets the TutorialPhaseData component on the entity with:

  • m_Type = TutorialPhaseType.Balloon
  • m_OverrideCompletionDelay = m_OverrideCompletionDelay (inherited field) Call base.Initialize(entityManager, entity) first.

  • public override void GenerateTutorialLinks(EntityManager entityManager, NativeParallelHashSet<Entity> linkedPrefabs)
    Generates runtime links between this prefab and the prefabs that provide UI tags. Uses the PrefabSystem system to resolve PrefabBase -> Entity and adds those entities to linkedPrefabs for later runtime linking. Call base.GenerateTutorialLinks(entityManager, linkedPrefabs) first.

Nested-type method:

  • public void Write(IJsonWriter writer)
    Writes the BalloonUITarget to a JSON writer. The JSON contains:
  • Type (TypeNames.kTutorialBalloonUITarget)
  • "uiTag": m_UITagProvider.uiTag (or empty string if null)
  • "direction": m_BalloonDirection.ToString()
  • "alignment": m_BalloonAlignment.ToString()

Usage Example

// Example: creating a BalloonUITarget and assigning it to a prefab instance (pseudo-code)
var target = new TutorialBalloonPrefab.BalloonUITarget();
target.m_UITagProvider = someUIPrefab; // PrefabBase reference to a UI provider
target.m_BalloonDirection = TutorialBalloonPrefab.BalloonDirection.down;
target.m_BalloonAlignment = TutorialBalloonPrefab.BalloonAlignment.start;

var prefab = ScriptableObject.CreateInstance<TutorialBalloonPrefab>();
prefab.m_UITargets = new[] { target };

// At runtime the prefab system will:
// - Add the target's m_UITagProvider to dependencies via GetDependencies
// - Initialize the phase entity with TutorialPhaseType.Balloon via Initialize
// - Link the target UI prefab entity via GenerateTutorialLinks

Notes and tips: - Ensure m_UITagProvider references the correct PrefabBase that exposes the uiTag used to locate the UI element. - The balloon direction and alignment control visual placement; choose values to avoid overlapping other UI elements. - This prefab participates in the ECS-based tutorial flow — familiarity with EntityManager, PrefabSystem and TutorialPhaseData is required when connecting or troubleshooting phases.