Class 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.
Inherited Members
Namespace: Unity.Netcode
Syntax
[Serializable]
public class NetworkPrefabs
Fields
NetworkPrefabOverrideLinks
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
Type | Description |
---|---|
Dictionary<UInt32, NetworkPrefab> |
NetworkPrefabsLists
Edit-time scripted object containing a list of NetworkPrefabs.
Declaration
[SerializeField]
public List<NetworkPrefabsList> NetworkPrefabsLists
Field Value
Type | Description |
---|---|
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
Type | Description |
---|---|
Dictionary<UInt32, UInt32> |
Properties
Prefabs
Declaration
public IReadOnlyList<NetworkPrefab> Prefabs { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<NetworkPrefab> |
Methods
Add(NetworkPrefab)
Add a new NetworkPrefab instance to the list
Declaration
public bool Add(NetworkPrefab networkPrefab)
Parameters
Type | Name | Description |
---|---|---|
NetworkPrefab | networkPrefab |
Returns
Type | Description |
---|---|
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(NetworkPrefab)
Check if the given NetworkPrefab is present within the list
Declaration
public bool Contains(NetworkPrefab prefab)
Parameters
Type | Name | Description |
---|---|---|
NetworkPrefab | prefab | The prefab to check |
Returns
Type | Description |
---|---|
Boolean | Whether or not the prefab exists |
Contains(GameObject)
Check if the given GameObject is present as a prefab within the list
Declaration
public bool Contains(GameObject prefab)
Parameters
Type | Name | Description |
---|---|---|
GameObject | prefab | The prefab to check |
Returns
Type | Description |
---|---|
Boolean | Whether 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
Type | Name | Description |
---|---|---|
Boolean | warnInvalid |
Remove(NetworkPrefab)
Remove a NetworkPrefab instance from the list
Declaration
public void Remove(NetworkPrefab prefab)
Parameters
Type | Name | Description |
---|---|---|
NetworkPrefab | prefab |
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(GameObject)
Remove a NetworkPrefab instance with matching Prefab from the list
Declaration
public void Remove(GameObject prefab)
Parameters
Type | Name | Description |
---|---|---|
GameObject | prefab |
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.