Script Types
There are 3 main types of script - Local, Global and Prefabs.
Local Scripts
Local scripts are the default for the Script Editor, and are specific to the room they were made in.
These can contain Object Blocks, which are blocks that reference objects placed in the Map Editor.
Global Script
The Global Script is shared between every room, and can be used for behaviour that works throughout every room in the game.
The Global Script itself cannot contain Object Blocks, however it can still spawn objects using the Spawn Prefab block, and prefabs themselves contain their own scripts.
You can trigger actions in the Global Script from Local Scripts (and vice-versa) using the Broadcast and Receive blocks.
Note: The Global Script does not continue running between rooms, rather the game acts as if the contents of the Global Script are present in every Local Script.
This means that, for example, the Start block will run every time you enter a room, not the first time you enter the game.
Prefab Scripts
Prefab Scripts are tied to prefabs, and are spawned at the same time as the prefabs themselves. They are accessed by opening the Script Editor when inside of the Prefab Editor.
When multiple copies of the same prefab are spawned, they will each have their own individual copy of that prefab's script.
Note: Variables and Broadcast/Receive blocks are not local to prefab scripts, and will be shared between multiple copies of the same prefab.
Last updated