StageTimeBehaviour
class StageTime.SDK.StageTimeBehaviour
Base class for world scripts (like UdonSharpBehaviour). Add your script to a GameObject in the world and fill its public fields in the Inspector. When the world is built, the script is compiled to a sandboxed WebAssembly module and runs on every player's device.
Unity messages use their usual names: Start, Update, LateUpdate, FixedUpdate, OnEnable, OnDisable, OnTriggerEnter(Collider), OnTriggerExit(Collider).
Public methods without parameters are custom events: UI buttons and other scripts can call them. Other scripts can also read and write your fields (other.score) and call public methods with parameters or a result (other.AddPoints(5)).
Properties
InteractionText
string InteractionText
Text shown when a player points at this object (if it has Interact).
DisableInteractive
bool DisableInteractive
When true, players cannot interact with this object.
Events
Interact
virtual void Interact()
The local player clicked this object (it needs a collider). Runs on the clicking player only.
OnDeserialization
virtual void OnDeserialization()
Synced values changed (runs on everyone except the owner, after the new values are applied).
OnPlayerJoined
virtual void OnPlayerJoined(StageTimePlayer player)
A player joined. Also runs once for every player already in the room when you join.
OnPlayerLeft
virtual void OnPlayerLeft(StageTimePlayer player)
A player left the room.
OnOwnershipTransferred
virtual void OnOwnershipTransferred(StageTimePlayer player)
This object's owner changed (runs on everyone).
OnPickup
virtual void OnPickup()
The local player picked up this object (needs an STPickup).
OnDrop
virtual void OnDrop()
The local player dropped this object.
OnPickupUseDown
virtual void OnPickupUseDown()
The local player pressed the trigger (VR) or use button (desktop) while holding this object.
OnPickupUseUp
virtual void OnPickupUseUp()
The local player released the trigger / use button while holding this object.
OnSeatEntered
virtual void OnSeatEntered(StageTimePlayer player)
A player sat in this object's STSeat (runs on everyone).
OnSeatExited
virtual void OnSeatExited(StageTimePlayer player)
A player left this object's STSeat (runs on everyone).
OnPlayerTriggerEnter
virtual void OnPlayerTriggerEnter(StageTimePlayer player)
A player entered one of this object's trigger colliders (runs on everyone).
OnPlayerTriggerExit
virtual void OnPlayerTriggerExit(StageTimePlayer player)
A player left one of this object's trigger colliders (runs on everyone).
OnVideoStart
virtual void OnVideoStart()
This object's STVideoPlayer started a newly loaded video (runs on everyone).
OnVideoPlay
virtual void OnVideoPlay()
This object's STVideoPlayer resumed after a pause (runs on everyone).
OnVideoPause
virtual void OnVideoPause()
This object's STVideoPlayer paused (runs on everyone).
OnVideoEnd
virtual void OnVideoEnd()
This object's STVideoPlayer reached the end of a video that doesn't loop (runs on each device).
OnVideoError
virtual void OnVideoError()
This object's STVideoPlayer could not load or play its video (runs on each device).
Methods
SendCustomEvent
void SendCustomEvent(string eventName)
Runs the public method eventName on this script, locally.
SendCustomNetworkEvent
void SendCustomNetworkEvent(NetworkEventTarget target, string eventName)
Runs the public method eventName on the given players' copies of this script.
SendCustomEventDelayedSeconds
void SendCustomEventDelayedSeconds(string eventName, float delaySeconds)
Runs the public method eventName locally after delaySeconds.
SendCustomEventDelayedFrames
void SendCustomEventDelayedFrames(string eventName, int delayFrames)
Runs the public method eventName locally after delayFrames frames.
RequestSerialization
void RequestSerialization()
Sends this script's [Synced] values to everyone. Only the owner can. StageTime syncs changed values automatically, so calling this is optional; it exists so code written for manual sync works unchanged.
GetProgramVariable
object GetProgramVariable(string symbolName)
Reads the field symbolName of this script by name (any field, also private ones). Cast the result to the field's type: (int)other.GetProgramVariable("score"). A wrong type stops the script.
SetProgramVariable
void SetProgramVariable(string symbolName, object value)
Writes the field symbolName of this script by name. The value's type must be the field's type (5 for an int, 5f for a float). [Synced] fields need ownership, like your own.