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).
OnStringLoadSuccess
virtual void OnStringLoadSuccess()
This object's STStringDownloader finished a download; read its result (runs on each device).
OnStringLoadError
virtual void OnStringLoadError()
This object's STStringDownloader could not download; read its error (runs on each device).
OnImageLoadSuccess
virtual void OnImageLoadSuccess()
This object's STImageLoader loaded an image; read its result, width and height (runs on each device).
OnImageLoadError
virtual void OnImageLoadError()
This object's STImageLoader could not load an image; read its error (runs on each device).
OnDataLoaded
virtual void OnDataLoaded()
This object's STDataTable loaded its table (runs on each device).
OnDataError
virtual void OnDataError()
This object's STDataTable could not load its table; read its error (runs on each device).
OnQueueChanged
virtual void OnQueueChanged()
This object's STQueue changed (an entry was added or removed; also once after joining). Runs on each device.
OnInputJump
virtual void OnInputJump(bool value, STInputArgs args)
The local player pressed or released Jump (Space, A in VR, Y on a gamepad). Runs on that player's device.
OnInputUse
virtual void OnInputUse(bool value, STInputArgs args)
The local player pressed or released Use (left mouse button, right trigger in VR, right trigger on a gamepad).
OnInputGrab
virtual void OnInputGrab(bool value, STInputArgs args)
The local player pressed or released Grab (left mouse button, grip in VR, left shoulder on a gamepad).
OnInputDrop
virtual void OnInputDrop(bool value, STInputArgs args)
The local player pressed or released Drop (right mouse button, B / East on a gamepad). In VR, letting go of a grip with nothing left in that hand (with sticky grab, the release that lets the object go) raises a press and a release together.
OnInputSecondaryUse
virtual void OnInputSecondaryUse(bool value, STInputArgs args)
The local player pressed or released SecondaryUse (F, left trigger in VR, left trigger on a gamepad).
OnInputMoveHorizontal
virtual void OnInputMoveHorizontal(float value, STInputArgs args)
The local player's move input changed sideways (A/D, left stick), -1 to 1.
OnInputMoveVertical
virtual void OnInputMoveVertical(float value, STInputArgs args)
The local player's move input changed forwards/backwards (W/S, left stick), -1 to 1.
OnInputLookHorizontal
virtual void OnInputLookHorizontal(float value, STInputArgs args)
The local player's look input changed sideways (left/right arrows, right stick), -1 to 1.
OnInputLookVertical
virtual void OnInputLookVertical(float value, STInputArgs args)
The local player's look input changed up/down (up/down arrows, right stick), -1 to 1.
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.