Class NetworkPrefab
Class that represents a NetworkPrefab
Inherited Members
Namespace: Unity.Netcode
Assembly: Unity.Netcode.Runtime.dll
Syntax
[Serializable]
public class NetworkPrefab
  Fields
Override
The override settings for this NetworkPrefab
Declaration
public NetworkPrefabOverride Override
  Field Value
| Type | Description | 
|---|---|
| NetworkPrefabOverride | 
OverridingTargetPrefab
The prefab to replace (override) the source prefab with
Declaration
public GameObject OverridingTargetPrefab
  Field Value
| Type | Description | 
|---|---|
| GameObject | 
Prefab
Asset reference of the network prefab
Declaration
public GameObject Prefab
  Field Value
| Type | Description | 
|---|---|
| GameObject | 
SourceHashToOverride
Used when hash is selected for the source prefab to override value (i.e. a direct reference is not possible such as in a multi-project pattern)
Declaration
public uint SourceHashToOverride
  Field Value
| Type | Description | 
|---|---|
| uint | 
SourcePrefabToOverride
Used when prefab is selected for the source prefab to override value (i.e. direct reference, the prefab is within the same project) We keep a separate value as the user might want to have something different than the default Prefab for the SourcePrefabToOverride
Declaration
public GameObject SourcePrefabToOverride
  Field Value
| Type | Description | 
|---|---|
| GameObject | 
Properties
SourcePrefabGlobalObjectIdHash
Gets the GlobalObjectIdHash of the source prefab based on the current override settings.
Declaration
public uint SourcePrefabGlobalObjectIdHash { get; }
  Property Value
| Type | Description | 
|---|---|
| uint | The hash value identifying the source prefab.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| InvalidOperationException | Thrown when required prefab references are missing or invalid.  | 
      
| ArgumentOutOfRangeException | Thrown when Override has an invalid value.  | 
      
TargetPrefabGlobalObjectIdHash
Gets the GlobalObjectIdHash of the target prefab when using prefab overrides.
Declaration
public uint TargetPrefabGlobalObjectIdHash { get; }
  Property Value
| Type | Description | 
|---|---|
| uint | The hash value identifying the target prefab, or 0 if no override is set.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| InvalidOperationException | Thrown when required prefab references are missing or invalid.  | 
      
| ArgumentOutOfRangeException | Thrown when Override has an invalid value.  | 
      
Methods
Equals(NetworkPrefab)
Compares this NetworkPrefab with another to determine equality.
Declaration
public bool Equals(NetworkPrefab other)
  Parameters
| Type | Name | Description | 
|---|---|---|
| NetworkPrefab | other | The NetworkPrefab to compare against.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | True if all fields match between the two NetworkPrefabs, false otherwise.  | 
      
ToString()
Returns a string representation of this NetworkPrefab's source and target hash values.
Declaration
public override string ToString()
  Returns
| Type | Description | 
|---|---|
| string | A string containing the source and target hash values.  | 
      
Overrides
Validate(int)
Validates the NetworkPrefab configuration to ensure all required fields are properly set.
Declaration
public bool Validate(int index = -1)
  Parameters
| Type | Name | Description | 
|---|---|---|
| int | index | Optional index used for error reporting when validating lists of prefabs.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | True if the NetworkPrefab is valid and ready for use, false otherwise.  |