SNetworking
| 函数 | SendEvent | Send a networking event event that will be received by other components in the scene with the same network name. |
| 函数 | ReceiveEvent | Invoke an event on the networking component. |
| 属性 | Enabled | Whether the simple networking component is Enabled or not |
| 属性 | Instanced | Returns whether this networking component is instanced or not. |
| 属性 | NetworkName | Returns or sets the name of the network. |
| 属性 | Ready | Return whether the networking component is ready to send or not (is initialized). |
| 属性 | EventCount | Return the number of events this component is waiting to receive. |
| 属性 | EventNames | Return a list of names of events that this component will receive. |
| 属性 | GameObject | – |
函数
SendEvent
Send a networking event event that will be received by other components in the scene with the same network name.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| eventName | string | – |
返回值
void
示例
Space.Host.ExecutingObject.Networking.SendEvent("Light On")
ReceiveEvent
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.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| eventName | string | – |
返回值
void
示例
Space.Host.ExecutingObject.Networking.ReceiveEvent("Light On")
属性
Enabled
Whether the simple networking component is Enabled or not
示例
Space.Host.ExecutingObject.Networking.Enabled = true
Instanced只读
Returns whether this networking component is instanced or not.
示例
isInstanced = Space.Host.ExecutingObject.Networking.Instanced
NetworkName
Returns or sets the name of the network. Network name must be at least 20 characters long without trailing or leading spaces.
示例
Space.Host.ExecutingObject.Networking.NetworkName = "Example Network Name 1"
Ready只读
Return whether the networking component is ready to send or not (is initialized).
示例
isReady = Space.Host.ExecutingObject.Networking.Ready
EventCount只读
Return the number of events this component is waiting to receive.
示例
count = Space.Host.ExecutingObject.Networking.EventCount
EventNames只读
Return a list of names of events that this component will receive.
示例
tableOfNames = Space.Host.ExecutingObject.Networking.EventNames
GameObject只读
示例
theGameObject = Space.Host.ExecutingObject.Networking.GameObject



