Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt

Use this file to discover all available pages before exploring further.

Namespace: Molca.Sequence
File: Assets/_Molca/_Core/Sequence/SequenceController.cs

When to use

Use SequenceController when you need ordered step execution with pause/resume support:
  • Training scenarios — the controller drives child Step components one-by-one, advancing on completion events.
  • Onboarding flows — sequential UI or tutorial steps where each must complete before the next begins.
  • For VR training, ScenarioActivity owns a SequenceController per activity — you rarely create one directly unless building custom flows.

Behaviour

  • Owns ordered child Step components.
  • State: SequenceStateIdle, Running, Paused, Completed.
  • While Running, calls UpdateStep() on the active step each frame.
  • Listens on EventDispatcher for Step.Completed / Step.FullyCompleted to advance.
Controller state (SequenceState): Typical linear step chain (sibling Step children under the controller): Parallel branches use Core step types such as ParallelStep where configured.

Unity events

OnSequenceStart, OnSequenceFinish, OnSequencePause, OnSequenceResume, OnStepChanged.

Dependencies

Uses [Inject] for EventDispatcher and ReferenceManager.

Editor tooling

Use the Sequence Visualizer (Molca → Utilities → Sequence Visualizer) to browse the step tree, change step type (edit mode, single selection), and open the CSV Step Importer.

Code

using Molca.Sequence;
using UnityEngine;

public class RunOnKey : MonoBehaviour
{
    [SerializeField] private SequenceController sequence;

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
            sequence.StartSequence();
    }
}
Prefer driving the controller from your scenario / training flow rather than input in production.

API Reference

MethodSignatureDescription
StartSequencevoid StartSequence()Begin sequence execution from the first step — sets state to Running
PauseSequencevoid PauseSequence()Pause the running sequence — sets state to Paused, stops step advancement
ResumeSequencevoid ResumeSequence()Resume a paused sequence — sets state back to Running
StopSequencevoid StopSequence()Stop the sequence and reset to Idle state
RestartSequencevoid RestartSequence()Stop and immediately restart the sequence from the first step
CompleteCurrentStepvoid CompleteCurrentStep()Manually complete the currently active step and advance to the next
CurrentStepStep CurrentStep { get; }Read-only property returning the currently active step, or null if sequence is not running

Troubleshooting

  • Sequence never starts: call StartSequence() only after RuntimeManager.WaitForInitialization() — the controller uses [Inject] for EventDispatcher and ReferenceManager.
  • Step never advances: SequenceController listens for Step.Completed / Step.FullyCompleted events via EventDispatcher. Verify the step calls Complete() and that the dispatcher is injected.
  • Steps run out of order: child Step components are executed in hierarchy order (top to bottom). Reorder in the Hierarchy or use the Sequence Visualizer.
  • Pause doesn’t freeze step logic: PauseSequence() stops advancement but does not pause Time.deltaTime. Steps with timer logic must check SequenceState themselves.

Unity Editor

Sequence Controller Hierarchy