Skip to main content

Unity.Netcode.NetworkPrefabs

A class that represents the runtime aspect of network prefabs. This class contains processed prefabs from the NetworkPrefabsList, as well as additional modifications (additions and removals) made at runtime.

Inheritance

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

Inherited Members

Object.ToString()

Object.Equals(Object)

Object.Equals(Object, Object)

Object.ReferenceEquals(Object, Object)

Object.GetHashCode()

Object.GetType()

Object.MemberwiseClone()

Namespace: System.Dynamic.ExpandoObject

Assembly: Netcode.dll

Syntax

[Serializable]
public class NetworkPrefabs

Fields

This dictionary provides a quick way to check and see if a NetworkPrefab has a NetworkPrefab override. Generated at runtime and OnValidate

Declaration

[NonSerialized]
public Dictionary<uint, NetworkPrefab> NetworkPrefabOverrideLinks

Field Value

TypeDescription
System.Collections.Generic.Dictionary\<System.UInt32, NetworkPrefab>

NetworkPrefabsLists

Edit-time scripted object containing a list of NetworkPrefabs.

Declaration

public List<NetworkPrefabsList> NetworkPrefabsLists

Field Value

TypeDescription
System.Collections.Generic.List\<NetworkPrefabsList>

Remarks

This field can be null if no prefabs are pre-configured. Runtime usages of NetworkPrefabs should not depend on this edit-time field for execution.

OverrideToNetworkPrefab

Declaration

[NonSerialized]
public Dictionary<uint, uint> OverrideToNetworkPrefab

Field Value

TypeDescription
System.Collections.Generic.Dictionary\<System.UInt32, System.UInt32>

Properties

Prefabs

Declaration

public IReadOnlyList<NetworkPrefab> Prefabs { get; }

Property Value

TypeDescription
IReadOnlyList\<NetworkPrefab>

Methods

Add(NetworkPrefab)

Add a new NetworkPrefab instance to the list

Declaration

public bool Add(NetworkPrefab networkPrefab)

Parameters

TypeNameDescription
NetworkPrefabnetworkPrefab

Returns

TypeDescription
System.Boolean

Remarks

The framework does not synchronize this list between clients. Any runtime changes must be handled manually. Any modifications made here are not persisted. Permanent configuration changes should be done through the NetworkPrefabsList scriptable object property.

Contains(GameObject)

Check if the given GameObject is present as a prefab within the list

Declaration

public bool Contains(GameObject prefab)

Parameters

TypeNameDescription
GameObjectprefabThe prefab to check

Returns

TypeDescription
System.BooleanWhether or not the prefab exists

Contains(NetworkPrefab)

Check if the given NetworkPrefab is present within the list

Declaration

public bool Contains(NetworkPrefab prefab)

Parameters

TypeNameDescription
NetworkPrefabprefabThe prefab to check

Returns

TypeDescription
System.BooleanWhether or not the prefab exists

Finalize()

Declaration

protected void Finalize()

Initialize(Boolean)

Processes the NetworkPrefabsList if one is present for use during runtime execution, else processes Prefabs.

Declaration

public void Initialize(bool warnInvalid = true)

Parameters

TypeNameDescription
System.BooleanwarnInvalid

Remove(GameObject)

Remove a NetworkPrefab instance with matching Prefab from the list

Declaration

public void Remove(GameObject prefab)

Parameters

TypeNameDescription
GameObjectprefab

Remarks

The framework does not synchronize this list between clients. Any runtime changes must be handled manually. Any modifications made here are not persisted. Permanent configuration changes should be done through the NetworkPrefabsList scriptable object property.

Remove(NetworkPrefab)

Remove a NetworkPrefab instance from the list

Declaration

public void Remove(NetworkPrefab prefab)

Parameters

TypeNameDescription
NetworkPrefabprefab

Remarks

The framework does not synchronize this list between clients. Any runtime changes must be handled manually. Any modifications made here are not persisted. Permanent configuration changes should be done through the NetworkPrefabsList scriptable object property.