This section explains what a Script is, how they are triggered, what order Frames are processed, etc.
A Script is the highest level object for creating content. It defines what will happen in your app. If you want a message to trigger when a user gets close to a place, you make that happen inside a Script. Scripts are where content creators define the content and logic that they want for their experience.
Each Script contains one or more Frames. Frames are arranged in an ordered tree. This tree will always contain at least a root Frame, and may contain child Frames underneath it. Content is added to Frames. When a Frame is processed, its Precondition is checked. If the Precondition is true, the Frame’s Resources will also be activated. Frame Conditions, Resource Events, and ordering Frames are ways a content creator can control how their experiences plays out.
When a Script is launched, the Script Processor will begin processing the Frames in the tree starting from the root Frame. Each script has a single root frame with a tree of 0-n subframes below it. The Script Processor processes each frame as follows:
- Evaluate the Preconditions and, if not met, wait for it to be met
- If no Precondition is present, it is considered to be met
- Activate resources
- Process from 1 to any subframes
- Wait for Postcondition if present. When Postcondition is met, “close” Frame:
- Deactivate all Resources
- Close all subframes
Specify the Startup Script
When your Motive-built app is launched for the first time, the Motive engine will launch a main Script that ‘jump-starts’ the experience. This main Script is often setup to launch other Scripts that contain the majority of content. There are two ways to tell the Motive engine which Script is the main Script. The first way is to explicitly state which Script is the main Script in the Motive Unity game object. In your Unity project, under Hierarchy > Motive > ScriptManager there are options to define which Scripts should be processed on launch. If ‘Auto Launch Mains’ is selected, then any Script that is called ‘main’ will be processed on launch. Alternatively, you can specify a list of Scripts to launch on startup under the option ‘Main Script Names’. You can combine both of these if desired.