Class NetworkSpawner
Manages spawnable network prefabs.
Implements
Inherited Members
Namespace: SuperNet.Unity.Components
Assembly: cs.temp.dll.dll
Syntax
public sealed class NetworkSpawner : NetworkComponent, INetworkAuthoritative
Fields
Locked
True if only authority can spawn. Set to false to let anybody spawn.
Declaration
public bool Locked
Field Value
| Type | Description |
|---|---|
| System.Boolean |
Parent
The parent transform to spawn under.
Declaration
public Transform Parent
Field Value
| Type | Description |
|---|---|
| Transform |
Prefab
The prefab to clone when spawning.
Declaration
public NetworkPrefab Prefab
Field Value
| Type | Description |
|---|---|
| NetworkPrefab |
SyncChannel
Network channel to use.
Declaration
public byte SyncChannel
Field Value
| Type | Description |
|---|---|
| System.Byte |
Properties
IsAuthority
True if we can spawn and despawn.
Declaration
public bool IsAuthority { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
Despawn(NetworkPrefab, Boolean)
Despawn an instantiated instance and optionally destroy it.
Declaration
public bool Despawn(NetworkPrefab instance, bool destroy = true)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkPrefab | instance | Instance to despawn. |
| System.Boolean | destroy | True to also destroy the instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if despawned, false if not. |
DespawnAll(Boolean)
Despawn all instantiated instances and optionally destroy them.
Declaration
public void DespawnAll(bool destroy = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | destroy | True to also destroy the instances. |
GetSpawnedPrefabs()
Get all spawned instances as a list.
Declaration
public IReadOnlyList<NetworkPrefab> GetSpawnedPrefabs()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyList<NetworkPrefab> | All spawned instances. |
OnNetworkConnect(Peer)
Declaration
public override void OnNetworkConnect(Peer peer)
Parameters
| Type | Name | Description |
|---|---|---|
| Peer | peer |
Overrides
OnNetworkDisconnect(Peer)
Declaration
public override void OnNetworkDisconnect(Peer peer)
Parameters
| Type | Name | Description |
|---|---|---|
| Peer | peer |
Overrides
OnNetworkMessage(Peer, Reader, MessageReceived)
Declaration
public override void OnNetworkMessage(Peer peer, Reader reader, MessageReceived info)
Parameters
| Type | Name | Description |
|---|---|---|
| Peer | peer | |
| Reader | reader | |
| MessageReceived | info |
Overrides
OnNetworkRegister()
Declaration
public override void OnNetworkRegister()
Overrides
OnNetworkResend(Peer, Peer, Reader, MessageReceived)
Declaration
public override bool OnNetworkResend(Peer origin, Peer peer, Reader reader, MessageReceived info)
Parameters
| Type | Name | Description |
|---|---|---|
| Peer | origin | |
| Peer | peer | |
| Reader | reader | |
| MessageReceived | info |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Overrides
SetAuthority(Boolean)
Update authority on this component.
Declaration
public void SetAuthority(bool authority)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | authority | Authority to set. |
Spawn(NetworkPrefab)
Spawn an already instantiated prefab.
Declaration
public void Spawn(NetworkPrefab instance)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkPrefab | instance | Instantiated prefab. |
Spawn(Boolean)
Spawn a network instance and notify the network.
Declaration
public NetworkPrefab Spawn(bool relativeToSpawner = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | relativeToSpawner | True to position the new object relative to the spawner. |
Returns
| Type | Description |
|---|---|
| NetworkPrefab | The instantiated clone. |
Spawn(Vector3, Quaternion, Boolean)
Spawn a network instance and notify the network.
Declaration
public NetworkPrefab Spawn(Vector3 position, Quaternion rotation, bool relativeToParent = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | position | Position for the new object. |
| Quaternion | rotation | Orientation of the new object. |
| System.Boolean | relativeToParent | True to position the new object relative to spawn parent. |
Returns
| Type | Description |
|---|---|
| NetworkPrefab | The instantiated clone. |
Start()
Declaration
protected override void Start()
Overrides
Explicit Interface Implementations
INetworkAuthoritative.OnNetworkAuthorityUpdate(Boolean, HostTimestamp)
Declaration
void INetworkAuthoritative.OnNetworkAuthorityUpdate(bool authority, HostTimestamp timestamp)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | authority | |
| HostTimestamp | timestamp |