Skip to main content
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.

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

Hierarchy: SequenceController parent with Step children collapsed/expanded; Inspector: SequenceController.

Unity Hierarchy showing SequenceController and child Step objects