SScriptingRuntime
客户端组件
成员 10
| 函数 | GetResource | Get the resource by its name and return it. |
| 函数 | CallScriptFunction | Call registered script function with specified arguments. |
| 函数 | Reset | Reset event members to their initial values. |
| 函数 | GetPublicVariable | Gets the public variable by its name and return it. |
| 函数 | SetPublicVariable | Set the property to public variable with name "name". |
| 函数 | InvokeEvent | Invokes the event with the name "name". |
| 属性 | Resources | Return a list of resource. |
| 属性 | Enabled | Whether the scripting runtime component is Enabled. |
| 属性 | ComponentName | The name of this component. |
| 属性 | GameObject | – |
函数
GetResource
Get the resource by its name and return it.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| name | string | – |
返回值
SResource
示例
Lua
resource = Space.Host.ExecutingObject.Script.GetResource("resource name")
CallScriptFunction
void CallScriptFunction(string name, params DynValue[] arguments)
void CallScriptFunction(string name)
Call registered script function with specified arguments.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| name | string | – |
| arguments | params DynValue[] | – |
返回值
void
示例
Lua
resource = Space.Host.ExecutingObject.Script.CallScriptFunction("FunctionName")
--or
resource = Space.Host.ExecutingObject.Script.CallScriptFunction("FunctionName", tableWithArguments)
Reset
void Reset()
Reset event members to their initial values.
返回值
void
示例
Lua
Space.Host.ExecutingObject.Script.Reset()
GetPublicVariable
object GetPublicVariable(string name)
Gets the public variable by its name and return it.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| name | string | – |
返回值
object
示例
Lua
publicVariable = Space.Host.ExecutingObject.Script.GetPublicVariable("variableName")
SetPublicVariable
void SetPublicVariable(string name, DynValue property, bool persistent = false)
Set the property to public variable with name "name".
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| name | string | – |
| property | DynValue | – |
| persistent | bool | false |
返回值
void
示例
Lua
Space.Host.ExecutingObject.Script.SetPublicVariable("VariableName",5,true)
InvokeEvent
void InvokeEvent(string name)
Invokes the event with the name "name".
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| name | string | – |
返回值
void
示例
Lua
Space.Host.ExecutingObject.Script.InvokeEvent("EventName")
属性
Resources只读
Return a list of resource.
示例
Lua
tableResources = Space.Host.ExecutingObject.Script.Resources
Enabled
bool Enabled {get; set; }
Whether the scripting runtime component is Enabled.
示例
Lua
Space.Host.ExecutingObject.Script.Enabled = true
ComponentName只读
string ComponentName {get; }
The name of this component.
示例
Lua
componentName = Space.Host.ExecutingObject.Script.ComponentName
GameObject只读
示例
Lua
theGameObject = Space.Host.ExecutingObject.Script.GameObject



