Skip to content

Conductor (Unity API)

Erik Loyer edited this page Jun 30, 2018 · 5 revisions

To use Stepwise in your Unity project, at a minumum you'll need to add the Conductor component to a game object. It allows you to load stories, and contains the Score object, the brains of the currently loaded story.

Public Properties

Property Type Description
dataFile TextAsset If you drag a TextAsset into this property slot in the Conductor's inspector, the Conductor will attempt to load it automatically on startup.
score Score Manages execution of the currently loaded story.

Public Methods

Load(TextAsset file)

Attempts to load the given text file as a Stepwise script. The file's contents will first be parsed as Stepwise XML, and if that fails, then as a plain text file where line breaks are used to delimit steps.

Load(string text)

Attempts to load the given string as a Stepwise script. The string will first be parsed as Stepwise XML, and if that fails, then as a plain text file where line breaks are used to delimit steps.

Reset()

Resets the current story to a pristine state.

NextStep()

Executes the next step in the current sequence of the current story. This may result in more than one actual step being executed. Subscribe to the Step.OnStepExecuted event to be notified as each step occurs.

Events

OnScoreLoading

This event is called when the Conductor begins loading a new script into its Score. You can subscribe to this event as follows:

void Start() {
	Conductor.OnScoreLoad += HandleScoreLoading
}

public virtual void HandleScoreLoading(Conductor conductor) {
	// attempting to load a new script into the score
}

OnScorePrepared

This event is called when a new script has successfully been loaded into the Score. You can subscribe to this event as follows:

void Start() {
	Conductor.OnScorePrepared += HandleScorePrepared
}

public virtual void HandleScorePrepared(Score score) {
	// a new script has been loaded into the score
}