Breakroom is now Sinewave Campus. Book a meeting

SScriptingRuntime

客户端组件
在此类中GetResource
  1. 函数
  2. GetResource
  3. CallScriptFunction
  4. Reset
  5. GetPublicVariable
  6. SetPublicVariable
  7. InvokeEvent
  8. 属性
  9. Resources
  10. Enabled
  11. ComponentName
  12. GameObject
成员 10
函数GetResourceGet the resource by its name and return it.
函数CallScriptFunctionCall registered script function with specified arguments.
函数ResetReset event members to their initial values.
函数GetPublicVariableGets the public variable by its name and return it.
函数SetPublicVariableSet the property to public variable with name "name".
函数InvokeEventInvokes the event with the name "name".
属性ResourcesReturn a list of resource.
属性EnabledWhether the scripting runtime component is Enabled.
属性ComponentNameThe name of this component.
属性GameObject–

函数​

GetResource​

SResource GetResource(string name)

Get the resource by its name and return it.

参数

名称类型默认值
namestring–

返回值

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.

参数

名称类型默认值
namestring–
argumentsparams 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.

参数

名称类型默认值
namestring–

返回值

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".

参数

名称类型默认值
namestring–
propertyDynValue–
persistentboolfalse

返回值

void

示例

Lua
Space.Host.ExecutingObject.Script.SetPublicVariable("VariableName",5,true)

InvokeEvent​

void InvokeEvent(string name)

Invokes the event with the name "name".

参数

名称类型默认值
namestring–

返回值

void

示例

Lua
Space.Host.ExecutingObject.Script.InvokeEvent("EventName")

属性​

Resources只读​

SResource[] Resources {get; }

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只读​

SGameObject GameObject {get; }

示例

Lua
theGameObject = Space.Host.ExecutingObject.Script.GameObject