SScript
在此类中TypeName
- 函数
- Type
Name - Tracking
Allowed - Tracking
Request - Get
Resource - Log
Event - Log
- 属性
- Inventory
- Persistence
- Scene
- Grid
- Host
- Physics
- Math
- String
- Input
- Camera
- Web
Services - Network
- PostFX
- Audio
Analyser - Tween
- UI
- Dialogues
- Shared
- Quests
- Economy
- Groups
- Activity
- Render
Settings - Profile
- Photos
- Videos
- Music
Directory - Journey
- Game
Tester - Runtime
Type - Platform
- SessionID
- In
Editor - Version
- Full
Version String - Resources
- Time
- Server
Time - Local
Time - Login
Time - Server
Time Unix - Local
Time Unix - Delta
Time - Preview
Server - Component
Name
| 函数 | TypeName | Return the type name of the value. |
| 函数 | TrackingAllowed | Returns true on white-label grids when the user has opted into tracking for the given key. |
| 函数 | TrackingRequest | Displays a consent prompt (EULA-style) asking the user to allow tracking for a given key. |
| 函数 | GetResource | Returns a reference to a SResource using it's Resource name. |
| 函数 | LogEvent | Logs an analytics event to the server on white-label grids. |
| 函数 | Log | Log a message to console. |
| 属性 | Inventory | Allows access to the users inventory |
| 属性 | Persistence | Stores information between user sessions, and for other users |
| 属性 | Scene | Allows access to the current scene graph (objects and avatars in the scene, and other information) |
| 属性 | Grid | – |
| 属性 | Host | Access information about the current scripting runtime host |
| 属性 | Physics | Call physics-related commands, and variables, such as raycasting |
| 属性 | Math | Math related functions (Sin, Cos, Tan, etc) |
| 属性 | String | Miscellaneous additional string functions (e.g. MD5Sum) |
| 属性 | Input | Input device related functions (mouse position, keyboard state) |
| 属性 | Camera | Take and control the users camera |
| 属性 | WebServices | Call remote web services to designated hosts (will not work with arbitrary domains, see page for details) |
| 属性 | Network | Send data to other clients through the region server |
| 属性 | PostFX | – |
| 属性 | AudioAnalyser | – |
| 属性 | Tween | – |
| 属性 | UI | – |
| 属性 | Dialogues | – |
| 属性 | Shared | – |
| 属性 | Quests | – |
| 属性 | Economy | – |
| 属性 | Groups | – |
| 属性 | Activity | – |
| 属性 | RenderSettings | – |
| 属性 | Profile | – |
| 属性 | Photos | – |
| 属性 | Videos | – |
| 属性 | MusicDirectory | – |
| 属性 | Journey | – |
| 属性 | GameTester | – |
| 属性 | RuntimeType | Return current RuntimeType name. |
| 属性 | Platform | Return current platform name. |
| 属性 | SessionID | Return current SessionID. |
| 属性 | InEditor | Return true if in unity editor. |
| 属性 | Version | Returns the numeric build version of the viewer (for programmatic comparisons). |
| 属性 | FullVersionString | Returns the full build version display string tied to release notes (e.g., "2025.6f210"). |
| 属性 | Resources | – |
| 属性 | Time | Returns time at the beginning of this frame. |
| 属性 | ServerTime | Returns current server time. |
| 属性 | LocalTime | Returns current local time. |
| 属性 | LoginTime | Returns how long player has been logged in (in seconds). |
| 属性 | ServerTimeUnix | Returns the server time unix timestamp. |
| 属性 | LocalTimeUnix | Returns the local time unix timestamp. |
| 属性 | DeltaTime | The completion time in seconds since the last frame. |
| 属性 | PreviewServer | Return true if in preview server. |
| 属性 | ComponentName | The name of this component. |
函数
TypeName
Return the type name of the value.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| dv | DynValue | – |
返回值
string
示例
typeName = Space.TypeName("123")
TrackingAllowed
Returns true on white-label grids when the user has opted into tracking for the given key. Always returns false on the main grid.
参数
| 参数 | 类型 | 说明 |
|---|---|---|
| key | string | A unique identifier used to store and look up the user's tracking consent. |
返回值
bool
示例
isTrackingAllowed = Space.TrackingAllowed('3423423423423')
TrackingRequest
Displays a consent prompt (EULA-style) asking the user to allow tracking for a given key. On white-label grids, stores the user's choice and invokes the callback with a boolean indicating consent. On the main grid, this does nothing.
参数
| 参数 | 类型 | 说明 |
|---|---|---|
| key | string | A unique identifier used to store and look up the user's tracking consent. |
| privacynotice | string | The privacy notice text to display in the consent dialog. |
| callback | Closure | A function invoked with one boolean parameter: true if allowed, false otherwise. |
| force | bool | If true, show the prompt even if a stored decision exists. Defaults to false. |
返回值
void
示例
-- Request consent (white-label only). The callback receives a boolean 'allowed'.
Space.TrackingRequest('24234234234234', 'A notice message', function(allowed)
if allowed then
Space.Log("Tracking allowed")
else
Space.Log("Tracking denied")
end
end)
-- or force re-prompt even if a decision was saved previously:
Space.TrackingRequest('24234234234234', 'A notice message', function(allowed) end, true)
GetResource
Returns a reference to a SResource using it's Resource name.
参数
| 参数 | 类型 | 说明 |
|---|---|---|
| name | string | Name of the Resource as set in the Scripting Runtime Component (Resources section) |
返回值
SResource
示例
aResource = Space.GetResource("ResourceName")
LogEvent
Logs an analytics event to the server on white-label grids.
参数
| 参数 | 类型 | 说明 |
|---|---|---|
| eventName | string | The name of the analytics event. |
| value | float | A numeric value associated with the event. |
| position | SVector | A world position to associate with the event. |
返回值
void
示例
Space.LogEvent('event name', 2.0, Vector.New(0,0,0) )
Log
Log a message to console.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| text | DynValue | – |
| logToFile | bool | false |
| text | string | – |
返回值
void
示例
Space.Log(Color.Blue)
--or
Space.Log("Log")
--or
Space.Log("Log",true)
属性
Inventory只读
Allows access to the users inventory
示例
inventory = Space.Inventory
Persistence只读
Stores information between user sessions, and for other users
示例
``` persistence = Space.Persistence ```
Scene只读
Allows access to the current scene graph (objects and avatars in the scene, and other information)
示例
scene = Space.Scene
Grid只读
示例
grid = Space.Grid
Host只读
Access information about the current scripting runtime host
示例
host = Space.Host
Physics只读
Call physics-related commands, and variables, such as raycasting
示例
physics = Space.Physics
Math只读
Math related functions (Sin, Cos, Tan, etc)
示例
Space.Math.Ceil(4.0)
String只读
Miscellaneous additional string functions (e.g. MD5Sum)
示例
Space.String.GetBytes("some data")
Input只读
Input device related functions (mouse position, keyboard state)
示例
Space.Input.Vibrate(1,1,false)
Camera只读
Take and control the users camera
示例
obj = Space.Host.ExecutingObject
Space.Camera.LockCamera (obj)
WebServices只读
Call remote web services to designated hosts (will not work with arbitrary domains, see page for details)
示例
Space.WebServices.GetImage("example.com/mrlee.jpg")
Network只读
Send data to other clients through the region server
示例
Space.Network.SubscribeToNetwork("helloworld", gotAMessageFunction)
PostFX只读
示例
Space.PostFX
AudioAnalyser只读
示例
Space.AudioAnalyser
Tween只读
示例
Space.Tween
UI只读
示例
ui = Space.UI
Dialogues只读
示例
dialogues = Space.Dialogues
Shared只读
示例
shared = Space.Shared
Quests只读
示例
quests = Space.Quests
Economy只读
示例
economy = Space.Economy
Groups只读
示例
groups = Space.Groups
Activity只读
示例
``` activity = Space.Activity ```
RenderSettings只读
示例
renderSettings = Space.RenderSettings
Profile只读
示例
profile = Space.Profile
Photos只读
示例
photos = Space.Photos
Videos只读
示例
videos = Space.Videos
MusicDirectory只读
示例
musicDirectory = Space.MusicDirectory
Journey只读
示例
journey = Space.Journey
GameTester只读
示例
gameTester = Space.GameTester
RuntimeType只读
Return current RuntimeType name.
示例
runtimeType = Space.RuntimeType
Platform只读
Return current platform name.
示例
platform = Space.Platform
SessionID只读
Return current SessionID.
示例
sessionID = Space.SessionID
InEditor只读
Return true if in unity editor.
示例
isInEditor = Space.InEditor
--the below script checks if we are in Unity editor or in SS
--this way we can provide an alternative
--(Example: if we're using a function that doesn't work in Unity editor)
thisGameObject = Space.Host.ExecutingObject
if Space.InEditor then
avatarUsername = "Player Name"
else
avatarUsername = Space.Scene.GetAvatar(thisGameObject.Owner).Username --example: this doesn't work in Editor
end
Space.Log(avatarUsername)
Version只读
Returns the numeric build version of the viewer (for programmatic comparisons). In the Unity Editor this returns int.MaxValue; if unknown at runtime it returns -1.
示例
viewerVersion = Space.Version
FullVersionString只读
Returns the full build version display string tied to release notes (e.g., "2025.6f210"). Best for user-facing display and logging.
示例
viewerVersionString = Space.FullVersionString
Resources只读
示例
tableOfResources = Space.Resources
--the below script will search through the Scripting Runtime's resources
--and return the first instance of an Animation Clip
--[You need to add a few resources to the scripting runtime and make one of them an animation]
resources = Space.Resources
for i = 1, #resources do
if resources[i].Type == "AnimationClip" then
Space.Log("Resource #".. i .. " is an Animation Clip. The resource name is: " .. resources[i].Name)
break
end
end
Time只读
Returns time at the beginning of this frame.
示例
floatTime = Space.Time
--this script will update a UIText object with the current local time without using a coroutine
--(example: clock )
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
rateUpdate = 1.0
nextUpdate = 0.0
text = Space.Host.GetReference("Text").UIText
OnUpdate = function()
if Space.Time > nextUpdate then
nextUpdate = Space.Time + rateUpdate
text.Text = Space.LocalTime
end
}
Space.Host.ExecutingObject.OnUpdate(OnUpdate)
ServerTime只读
Returns current server time.
示例
serverTime = Space.ServerTime
--this script will update a UIText object with the current server time (UTC)
--(example: clock)
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
co = function()
while true do
text.Text = Space.ServerTime
coroutine.yield(1)
end
end
Space.Host.StartCoroutine(co)
LocalTime只读
Returns current local time.
示例
localTime = Space.LocalTime
--this script will update a UIText object with the current local time
--(example: clock)
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
co = function()
while true do
text.Text = Space.LocalTime
coroutine.yield(1)
end
end
Space.Host.StartCoroutine(co)
LoginTime只读
Returns how long player has been logged in (in seconds).
示例
loginTime = Space.LoginTime
--this script will update a UIText object with how long the user has been logged in (in seconds)
--(example: clock)
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
co = function()
while true do
text.Text = Space.LoginTime
coroutine.yield(1)
end
end
Space.Host.StartCoroutine(co)
ServerTimeUnix只读
Returns the server time unix timestamp.
示例
serverTimeUnix = Space.ServerTimeUnix
--this script will update a UIText object with the current server time unix timestamp
--(example: clock)
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
co = function()
while true do
text.Text = Space.ServerTimeUnix
coroutine.yield(1)
end
end
Space.Host.StartCoroutine(co)
LocalTimeUnix只读
Returns the local time unix timestamp.
示例
localTimeUnix = Space.LocalTimeUnix
--this script will update a UIText object with the current local time unix timestamp
--(example: clock)
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
co = function()
while true do
text.Text = Space.LocalTimeUnix
coroutine.yield(1)
end
end
Space.Host.StartCoroutine(co)
DeltaTime只读
The completion time in seconds since the last frame.
示例
deltaTime = Space.DeltaTime
--the below script rotates an object around Y axis but uses DeltaTime
--to make sure it's not dependant on client's Framerate (FPS)
--this way the object rotates per second not per frame
--(Example: Important movement in OnUpdate)
thisGameObject = Space.Host.ExecutingObject
OnUpdate = function()
currentY = thisGameObject.WorldRotation.EulerAngles.Y
newRotation = Quaternion.Euler(0, currentY + 1 * Space.DeltaTime, 0) --We multiplied 1 by Space.DeltaTime
thisGameObject.WorldRotation = newRotation
end
thisGameObject.OnUpdate(OnUpdate)
PreviewServer只读
Return true if in preview server.
示例
isInPreview = Space.PreviewServer
--this script will update a UIText object with "preview" or "live" depending
--whether we are on preview server or live server
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
OnUpdate = function()
if Space.PreviewServer then
text.Text = "Preview"
else
text.Text = "Live"
end
end
Space.Host.ExecutingObject.OnUpdate(OnUpdate)
ComponentName只读
The name of this component.
示例
componentName = Space.ComponentName



