Breakroom is now Sinewave Campus. Book a meeting

SNetworking

客户端组件
在此类中SendEvent
  1. 函数
  2. SendEvent
  3. ReceiveEvent
  4. 属性
  5. Enabled
  6. Instanced
  7. NetworkName
  8. Ready
  9. EventCount
  10. EventNames
  11. GameObject
成员 9
函数SendEventSend a networking event event that will be received by other components in the scene with the same network name.
函数ReceiveEventInvoke an event on the networking component.
属性EnabledWhether the simple networking component is Enabled or not
属性InstancedReturns whether this networking component is instanced or not.
属性NetworkNameReturns or sets the name of the network.
属性ReadyReturn whether the networking component is ready to send or not (is initialized).
属性EventCountReturn the number of events this component is waiting to receive.
属性EventNamesReturn a list of names of events that this component will receive.
属性GameObject–

函数​

SendEvent​

void SendEvent(string eventName)

Send a networking event event that will be received by other components in the scene with the same network name.

参数

名称类型默认值
eventNamestring–

返回值

void

示例

Lua
Space.Host.ExecutingObject.Networking.SendEvent("Light On")

ReceiveEvent​

void ReceiveEvent(string eventName)

Invoke an event on the networking component. Normally not necessary to do manually, as this happens automatically when receiving a matching event over the network, but may be useful to initialize a state.

参数

名称类型默认值
eventNamestring–

返回值

void

示例

Lua
Space.Host.ExecutingObject.Networking.ReceiveEvent("Light On")

属性​

Enabled​

bool Enabled {get; set; }

Whether the simple networking component is Enabled or not

示例

Lua
Space.Host.ExecutingObject.Networking.Enabled = true

Instanced只读​

bool Instanced {get; }

Returns whether this networking component is instanced or not.

示例

Lua
isInstanced = Space.Host.ExecutingObject.Networking.Instanced

NetworkName​

string NetworkName {get; set; }

Returns or sets the name of the network. Network name must be at least 20 characters long without trailing or leading spaces.

示例

Lua
Space.Host.ExecutingObject.Networking.NetworkName = "Example Network Name 1"

Ready只读​

bool Ready {get; }

Return whether the networking component is ready to send or not (is initialized).

示例

Lua
isReady = Space.Host.ExecutingObject.Networking.Ready

EventCount只读​

int EventCount {get; }

Return the number of events this component is waiting to receive.

示例

Lua
count = Space.Host.ExecutingObject.Networking.EventCount

EventNames只读​

string[] EventNames {get; }

Return a list of names of events that this component will receive.

示例

Lua
tableOfNames = Space.Host.ExecutingObject.Networking.EventNames

GameObject只读​

SGameObject GameObject {get; }

示例

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