Struct NetworkObjectReference
A helper struct for serializing Network
Inherited Members
Namespace: Unity.Netcode
Assembly: Unity.Netcode.Runtime.dll
Syntax
public struct NetworkObjectReference : INetworkSerializable, IEquatable<NetworkObjectReference>
Constructors
NetworkObjectReference(NetworkObject)
Creates a new instance of the Network
Declaration
public NetworkObjectReference(NetworkObject networkObject)
Parameters
Type | Name | Description |
---|---|---|
Network |
networkObject | The Network |
Exceptions
Type | Condition |
---|---|
Argument |
|
Argument |
NetworkObjectReference(GameObject)
Creates a new instance of the Network
Declaration
public NetworkObjectReference(GameObject gameObject)
Parameters
Type | Name | Description |
---|---|---|
Game |
gameObject | The GameObject from which the Network |
Exceptions
Type | Condition |
---|---|
Argument |
|
Argument |
Properties
NetworkObjectId
The Network
Declaration
public ulong NetworkObjectId { get; }
Property Value
Type | Description |
---|---|
ulong |
Methods
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj |
Returns
Type | Description |
---|---|
bool |
Overrides
Equals(NetworkObjectReference)
Declaration
public bool Equals(NetworkObjectReference other)
Parameters
Type | Name | Description |
---|---|---|
Network |
other |
Returns
Type | Description |
---|---|
bool |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
NetworkSerialize<T>(BufferSerializer<T>)
Provides bi-directional serialization to read and write the desired data to serialize this type.
Declaration
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
Parameters
Type | Name | Description |
---|---|---|
Buffer |
serializer | The serializer to use to read and write the data. |
Type Parameters
Name | Description |
---|---|
T | Either BufferSerializerReader or BufferSerializerWriter, depending whether the serializer is in read mode or write mode. |
TryGet(out NetworkObject, NetworkManager)
Tries to get the Network
Declaration
public bool TryGet(out NetworkObject networkObject, NetworkManager networkManager = null)
Parameters
Type | Name | Description |
---|---|---|
Network |
networkObject | The Network |
Network |
networkManager | The networkmanager. Uses Singleton to resolve if null. |
Returns
Type | Description |
---|---|
bool | True if the Network |
Operators
implicit operator NetworkObjectReference(NetworkObject)
Implicitly convert Network
Declaration
public static implicit operator NetworkObjectReference(NetworkObject networkObject)
Parameters
Type | Name | Description |
---|---|---|
Network |
networkObject | The Network |
Returns
Type | Description |
---|---|
Network |
The Network |
implicit operator NetworkObject(NetworkObjectReference)
Implicitly convert Network
Declaration
public static implicit operator NetworkObject(NetworkObjectReference networkObjectRef)
Parameters
Type | Name | Description |
---|---|---|
Network |
networkObjectRef | The Network |
Returns
Type | Description |
---|---|
Network |
The Network |
implicit operator GameObject(NetworkObjectReference)
Implicitly convert Network
Declaration
public static implicit operator GameObject(NetworkObjectReference networkObjectRef)
Parameters
Type | Name | Description |
---|---|---|
Network |
networkObjectRef | The Network |
Returns
Type | Description |
---|---|
Game |
This returns the Game |
implicit operator NetworkObjectReference(GameObject)
Implicitly convert Game
Declaration
public static implicit operator NetworkObjectReference(GameObject gameObject)
Parameters
Type | Name | Description |
---|---|---|
Game |
gameObject | The Game |
Returns
Type | Description |
---|---|
Network |
The Network |