ScriptAPI / Reference
Base Class
Scripts inherit from SimuScriptBase. Most callable helpers are protected, so they are used from inside your script class.
public virtual string ScriptName
Defaults to the class name. Used in logs and script event sender info.
public virtual string ScriptDescription
Optional description text for tools that surface script metadata.
protected GameObject gameObject
The object that owns this script instance.
protected Transform transform
The transform of the owning object.
protected Dictionary<string, GameObject> slots
Named object slots assigned by the runtime when available.
protected bool IsRuntimeMode
True when running in the runtime world rather than editor bootstrap mode.
protected virtual bool SyncTransformStateByDefault
Defaults to true. Override to disable automatic transform state sync at startup.
protected bool TransformStateSyncEnabled
Runtime switch for automatic transform state synchronization.
ScriptAPI / Types
Core Types
SceneObject
Serialized scene reference with ObjectId, Id, IsNull, Exists, gameObject, transform, GetComponent<T>, GetComponents<T>, child lookup, and parent lookup helpers.
Sitpoint : SceneObject
Scene object reference with SitpointId resolution for sitpoint components and settings.
SVLight : SceneObject
Scene object reference with a light property that resolves a Light on the object or in children.
InventoryItem
Inventory reference with InventoryId, Kind, Id, IsNull, IsEmpty, Exists, and normalization helpers.
Emote : InventoryItem
Inventory item specialized for emotes. Kind is Emote; EmoteId mirrors InventoryId.
SVUserInfo
User snapshot with Username, ObjectName, ObjectId, and PlayerObject.
SVSitpointInfo
Sit or stand snapshot with Username, SitpointId, ObjectName, ObjectId, Sitpoint, and PlayerObject.
SVInteractionInfo
Interactable callback data with Username, ObjectName, ObjectId, ScriptNetworkId, InteractionType, and Target.
SVChatCommandInfo
Chat command callback data with Username, UserId, player object fields, room ids, FullText, Command, ParameterText, and split Args.
SVSitpointInputInfo
Sitpoint input data with MoveX, MoveY, LookX, LookY, Jump, Sprint, Username, SitpointId, and Sitpoint.
SVTriggerInfo
Trigger callback data with EventType, IsPlayer, username, object name/id, trigger object id, OtherObject, and TriggerObject.
SVCollisionInfo
Collision callback data with IsPlayer, username, collided object name/id, collision object id, OtherObject, and CollisionObject.
SVTriggerEventType
Enum values: Enter, Exit.
Script Event Data
SVScriptEventData.Set(name, value)
Adds or replaces a named event value and returns the same data object.
Has(name)
Checks whether the data contains a key. Keys are case-insensitive.
Get(name, defaultValue)
Gets a raw value or default.
Get<T>(name, defaultValue)
Gets and converts a value to the requested type when possible.
TryGet<T>(name, out value)
Gets a typed value and reports whether the key existed.
GetString / GetInt / GetFloat / GetDouble / GetBool
Convenience typed accessors for common event payload values.
Copy()
Returns a shallow copy of the event data.
SVScriptEventData.From(params object[] pairs)
Builds event data from alternating name/value pairs.
Script Event Info
SVScriptEventInfo
Contains EventName, Group, FullName, SenderScriptName, SenderObjectId, SenderObject, and Data.
ScriptAPI / Lifecycle
Lifecycle And Mode Helpers
public virtual void Start()
Called when the script starts. Call base.Start() before custom setup.
public virtual void OnDestroy()
Called as the script is destroyed. Use for cleanup such as despawning objects or stopping state.
public virtual void OnEnable()
Called when the script is enabled.
public virtual void OnDisable()
Called when the script is disabled.
public virtual void OnEvent(string eventName, object data)
Generic event hook for runtime-dispatched events.
SetTransformStateSync / DisableTransformStateSync / EnableTransformStateSync
Control automatic transform state synchronization for this script.
protected void SetStateApplyPhase(int phase)
Advanced control for when state is applied. The base uses the update phase.
ScriptAPI / Users And Events
Users
OnUserJoin(SVUserInfo user)
Override to run logic when a user enters.
OnUserPart(SVUserInfo user)
Override to run logic when a user leaves.
OnUserSit(SVSitpointInfo sitpoint)
Override to run logic when a user sits.
OnUserStand(SVSitpointInfo sitpoint)
Override to run logic when a user stands.
GetUsers()
Returns a list of active user snapshots.
GetUsernames()
Returns the active usernames known by the runtime.
ForEachUser(Action<SVUserInfo> callback)
Runs the callback for each active user and logs callback errors.
Script Events
Script events are local runtime messages. Use eventName for global listeners, or eventName@group for a grouped event key. Posting name@group notifies listeners of name and listeners of name@group.
CreateScriptEventData(params object[] nameValuePairs)
Builds SVScriptEventData from alternating name and value arguments.
NewScriptEventData(params object[] nameValuePairs)
Alias for CreateScriptEventData.
ListenForScriptEvent(string eventName, Action<SVScriptEventInfo> callback)
Registers a callback with full sender and payload details.
ListenForScriptEvent(string eventName, Action<SVScriptEventData> callback)
Registers a callback that receives only the payload data.
StopListeningForScriptEvent(string eventName = null)
Stops this script's event subscriptions. With no name, removes all subscriptions owned by this script.
PostScriptEvent(string eventName)
Posts an event with empty data.
PostScriptEvent(string eventName, SVScriptEventData data)
Posts an event with structured data.
PostScriptEvent(string eventName, params object[] nameValuePairs)
Posts an event from alternating name and value arguments.
ScriptAPI / Dialogs
Dialogs
ShowDialog queues a modal dialog client command. Provide targetUsername for a single user, or leave it empty for everyone.
ShowDialog(title, message, targetUsername = null, icon = Info, buttons = OK)
Shows a simple dialog with optional target, icon, and button set.
ShowDialog(title, message, SSModalDialogIcon icon)
Shows an icon dialog with an OK button.
ShowDialog(title, message, icon, buttons, targetUsername = null)
Shows a dialog with explicit icon and button configuration.
ShowDialog(title, message, icon, buttons, onResult, targetUsername = null)
Shows a dialog and invokes the callback with SSModalDialogResult.
ShowDialog(title, message, icon, onResult, targetUsername = null)
Shows an OK dialog and invokes the callback.
Dialog Enums
SSModalDialogIcon
None, Info, Warning, Error, Success.
SSModalDialogButtons
OK, OKCancel, YesNo, YesNoCancel, Custom.
SSModalDialogResult
None, OK, Cancel, Yes, No, Custom1, Custom2, Custom3.
ScriptAPI / Transforms
Coroutines And Self Transform Helpers
StartCoroutine(IEnumerator routine)
Starts a coroutine using the script runtime runner.
yield return new WaitForSeconds(seconds)
Waits inside a coroutine. For example, yield return new WaitForSeconds(0.5f); waits half a second.
StopCoroutine(Coroutine routine)
Stops a coroutine started through the runtime runner.
StopAllCoroutines()
Stops all coroutines on the runner.
Move(Vector3 offset)
Adds the offset to this script object's world position.
Rotate(Vector3 eulerAngles)
Rotates this script object in world space.
RotateAround(Vector3 axis, float angle)
Rotates this script object around a world-space axis.
SetPosition / SetRotation / SetScale
Sets this script object's world position, world rotation, or local scale.
GetPosition / GetRotation / GetScale
Reads this script object's world position, world euler rotation, or local scale.
ScriptAPI / Object Commands
Self Object Client Commands
These helpers queue commands for the object that owns the script. Most include optional targetUsername, component index, and includeChildren parameters.
SetMaterialFloat(int materialIndex, string propertyName, float value, string targetUsername = null, int rendererIndex = 0, bool includeChildren = true)Sets a material float property.
SetMaterialColor(int materialIndex, string propertyName, Color value, string targetUsername = null, int rendererIndex = 0, bool includeChildren = true)Sets a material color property.
SetMaterialKeyword(int materialIndex, string keyword, bool enabled, string targetUsername = null, int rendererIndex = 0, bool includeChildren = true)Enables or disables a material keyword.
SetRendererVisible(bool visible, string targetUsername = null, int rendererIndex = 0, bool includeChildren = true)Sets renderer visibility.
SetLightEnabled / SetLightIntensity / SetLightColorControls a light component by index.
SetAudioVolume / SetAudioPitch / PlayAudio / StopAudioControls an audio source by index.
SetAnimatorTrigger / SetAnimatorBoolControls animator parameters by index.
EnableAnimatorSync / DisableAnimatorSyncPeriodically sends current Animator state to clients.
EnableLegacyAnimationSync / DisableLegacyAnimationSyncPeriodically sends current legacy Animation state to clients.
SyncAnimatorState / SyncLegacyAnimationStateSends current animation state once.
SetLocalPosition / SetLocalRotation / SetLocalScaleQueues a client transform command for this object.
SetColliderEnabled / SetRigidbodyKinematicControls collider or rigidbody state by index.
Target Object Client Commands
These overloads take SceneObject targetObject first and queue the command for that object id.
SetMaterialFloat(SceneObject targetObject, int materialIndex, string propertyName, float value, string targetUsername = null, int rendererIndex = 0, bool includeChildren = true)Sets a target object's material float property.
SetMaterialColor(SceneObject targetObject, int materialIndex, string propertyName, Color value, string targetUsername = null, int rendererIndex = 0, bool includeChildren = true)Sets a target object's material color property.
SetMaterialKeyword(SceneObject targetObject, int materialIndex, string keyword, bool enabled, string targetUsername = null, int rendererIndex = 0, bool includeChildren = true)Enables or disables a target object's material keyword.
SetRendererVisible(SceneObject targetObject, bool visible, string targetUsername = null, int rendererIndex = 0, bool includeChildren = true)Sets target renderer visibility.
SetLightEnabled / SetLightIntensity / SetLightColorControls a target light by index.
SetAudioVolume / SetAudioPitch / PlayAudio / StopAudioControls a target audio source by index.
SetAnimatorTrigger / SetAnimatorBoolControls a target animator by index.
SyncAnimatorState / SyncLegacyAnimationStateSends a target object's current animation state once.
SetLocalPosition / SetLocalRotation / SetLocalScaleQueues a client transform command for a target object.
SetColliderEnabled / SetRigidbodyKinematicControls a target collider or rigidbody by index.
ScriptAPI / Material Emission
Material Emission At Runtime
SV Standard Lit materials expose _EmissionIntensity for glow strength and _EmissionColor for glow color. Set intensity above 0 to make the material emissive, and set intensity back to 0 with a black emission color to turn it off.
SetMaterialFloat(target, materialIndex, "_EmissionIntensity", level)
Sets the emission level. 0 is off; values like 1 to 3 are useful for visible glow.
SetMaterialColor(target, materialIndex, "_EmissionColor", color)
Sets the emitted color. Use a bright color while lit and Color.black when resetting.
_SVEmissionUseMap
Leave this off for normal SV Standard Lit glow through the base texture. Turn it on only when the material has a dedicated emission mask map.
SetMaterialFloat(target, 0, "_EmissionIntensity", 1.5f);
SetMaterialColor(target, 0, "_EmissionColor", Color.white);
SetMaterialFloat(target, 0, "_EmissionIntensity", 0f);
SetMaterialColor(target, 0, "_EmissionColor", Color.black);
ScriptAPI / Spritesheets
Spritesheet Material Helpers
Spritesheet helpers are target-object commands. They expect materials with the spritesheet properties used by the runtime animator.
SetSpritesheetFrame(SceneObject targetObject, int frame, string targetUsername = null, int rendererIndex = 0, int materialIndex = 0, bool includeChildren = true)
Sets the target material frame.
SetSpritesheetPlayback(SceneObject targetObject, bool animate, float autoAdvanceSeconds, bool loop, string targetUsername = null, int rendererIndex = 0, int materialIndex = 0, bool includeChildren = true)
Sets animation, frame advance interval, and looping.
SetSpritesheetMaterial(SceneObject targetObject, int? frame = null, bool? animate = null, float? autoAdvanceSeconds = null, bool? loop = null, bool? affectMaps = null, string targetUsername = null, int rendererIndex = 0, int materialIndex = 0, bool includeChildren = true)
Applies any combination of frame, playback, loop, and map-affecting settings. Commands are persistent for late-joining clients.
ScriptAPI / Spawning
Inventory Spawning And Player Controls
SpawnInventoryItem(InventoryItem item, Vector3 position, Vector3 eulerAngles, Vector3 scale)
Spawns an inventory item, returns a SceneObject, and queues a persistent spawn command for clients.
DespawnSpawnedObject(SceneObject spawnedObject)
Removes a spawned object, clears its persistent spawn command, and queues a despawn command.
TeleportPlayer(string username, Vector3 position, Vector3 eulerAngles)
Queues a teleport command for one username.
PlayPlayerEmote(string username, string emoteId)
Requests an emote for one user.
PlayPlayerEmote(string username, Emote emote)
Requests an emote using an Emote inventory reference.
PlayEmoteForAll / StopPlayerEmote / StopAllPlayerEmotes
Controls emotes globally or by username.
SetPlayerScale(string username, float scale)
Sets uniform scale for one user.
SetPlayerScale(string username, Vector3 scale)
Sets non-uniform scale for one user.
SetAllPlayerScales(float scale) / SetAllPlayerScales(Vector3 scale)
Sets player scale for everyone.
SetMediaScreenUrl(string url)
Sets all media screens to a URL.
SetMediaScreenUrl(string mediaScreenId, string url)
Sets one media screen id, or * for all media screens.
ScriptAPI / Chat
Chat Commands And Room Messages
RegisterChatCommand(Action<SVChatCommandInfo> callback)
Listens for every non-system slash command that was not handled by the game client command list.
RegisterChatCommand(string command, Action<SVChatCommandInfo> callback)
Listens for one custom slash command such as /roll. The leading slash is optional.
StopListeningForChatCommand(string command = null)
Removes this script's chat command listener for one command, or all chat command listeners when omitted.
SendScriptChat(string message)
Inserts a room chat history entry from the fake username [Script].
ScriptAPI / Interaction
Interactables, Triggers, Collisions, And Sitpoint Input
MakeInteractable(Action<SVInteractionInfo> onInteract, bool highlight = true, string targetUsername = null, bool includeChildren = true, float raycastDistance = 10f, string hintText = null)
Makes the script object interactable and calls the callback when activated.
MakeInteractable(SceneObject targetObject, Action<SVInteractionInfo> onInteract, bool highlight = true, string targetUsername = null, bool includeChildren = true, float raycastDistance = 10f, string hintText = null)
Makes a target object interactable.
RegisterTrigger(Action<SVTriggerInfo> onEnter, Action<SVTriggerInfo> onExit = null, bool includeChildren = true)
Registers trigger callbacks on the script object.
RegisterTrigger(SceneObject targetObject, Action<SVTriggerInfo> onEnter, Action<SVTriggerInfo> onExit = null, bool includeChildren = true)
Registers trigger callbacks on a target object.
RegisterCollision(Action<SVCollisionInfo> onCollision, bool includeChildren = true)
Registers a server-side collision callback on the script object. The callback receives the collided object's ObjectName and ObjectId.
RegisterCollision(SceneObject targetObject, Action<SVCollisionInfo> onCollision, bool includeChildren = true)
Registers a server-side collision callback on a target object or its child colliders.
RegisterSitpointInput(Action<SVSitpointInputInfo> onInput)
Registers a callback for input from the sitpoint associated with this script's network id.
ScriptAPI / Advanced
Advanced Helpers
EmitClientCommand(string command, string payloadJson, string targetUsername = null)
Queues a raw client command for this script object's network id.
EmitClientCommand(SceneObject targetObject, string command, string payloadJson, string targetUsername = null)
Queues a raw client command for a target object id.
Log(string msg)
Writes a normal log message prefixed with the script name.
LogWarning(string msg)
Writes a warning prefixed with the script name.
LogError(string msg)
Writes an error prefixed with the script name.