Skip to main content

MLAPI.NetworkObject

A component used to identify that a GameObject in the network

Inheritance#

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

Inherited Members#

MonoBehaviour.IsInvoking()

MonoBehaviour.CancelInvoke()

MonoBehaviour.Invoke(String, Single)

MonoBehaviour.InvokeRepeating(String, Single, Single)

MonoBehaviour.CancelInvoke(String)

MonoBehaviour.IsInvoking(String)

MonoBehaviour.StartCoroutine(String)

MonoBehaviour.StartCoroutine(String, Object)

MonoBehaviour.StartCoroutine(IEnumerator)

MonoBehaviour.StartCoroutine_Auto(IEnumerator)

MonoBehaviour.StopCoroutine(IEnumerator)

MonoBehaviour.StopCoroutine(Coroutine)

MonoBehaviour.StopCoroutine(String)

MonoBehaviour.StopAllCoroutines()

MonoBehaviour.print(Object)

MonoBehaviour.useGUILayout

MonoBehaviour.runInEditMode

Behaviour.enabled

Behaviour.isActiveAndEnabled

Component.GetComponent(Type)

Component.GetComponent<T>()

Component.GetComponent(String)

Component.GetComponentInChildren(Type, Boolean)

Component.GetComponentInChildren(Type)

Component.GetComponentInChildren<T>(Boolean)

Component.GetComponentInChildren<T>()

Component.GetComponentsInChildren(Type, Boolean)

Component.GetComponentsInChildren(Type)

Component.GetComponentsInChildren<T>(Boolean)

Component.GetComponentsInChildren<T>(Boolean, List<T>)"

Component.GetComponentsInChildren<T>()

Component.GetComponentsInChildren<T>(List<T>)"

Component.GetComponentInParent(Type)

Component.GetComponentInParent<T>()

Component.GetComponentsInParent(Type, Boolean)

Component.GetComponentsInParent(Type)

Component.GetComponentsInParent<T>(Boolean)

Component.GetComponentsInParent<T>(Boolean, List<T>)"

Component.GetComponentsInParent<T>()

Component.GetComponents(Type)

Component.GetComponents(Type, List<Component>)

Component.GetComponents<T>(List<T>)"

Component.GetComponents<T>()

Component.CompareTag(String)

Component.SendMessageUpwards(String, Object, SendMessageOptions)

Component.SendMessageUpwards(String, Object)

Component.SendMessageUpwards(String)

Component.SendMessageUpwards(String, SendMessageOptions)

Component.SendMessage(String, Object)

Component.SendMessage(String)

Component.SendMessage(String, Object, SendMessageOptions)

Component.SendMessage(String, SendMessageOptions)

Component.BroadcastMessage(String, Object, SendMessageOptions)

Component.BroadcastMessage(String, Object)

Component.BroadcastMessage(String)

Component.BroadcastMessage(String, SendMessageOptions)

Component.transform

Component.gameObject

Component.tag

Component.rigidbody

Component.rigidbody2D

Component.camera

Component.light

Component.animation

Component.constantForce

Component.renderer

Component.audio

Component.guiText

Component.networkView

Component.guiElement

Component.guiTexture

Component.collider

Component.collider2D

Component.hingeJoint

Component.particleEmitter

Component.particleSystem

Object.GetInstanceID()

Object.GetHashCode()

Object.Equals(Object)

Object.Instantiate(Object, Vector3, Quaternion)

Object.Instantiate(Object, Vector3, Quaternion, Transform)

Object.Instantiate(Object)

Object.Instantiate(Object, Transform)

Object.Instantiate(Object, Transform, Boolean)

Object.Instantiate<T>(T)"

Object.Instantiate<T>(T, Vector3, Quaternion)"

Object.Instantiate<T>(T, Vector3, Quaternion, Transform)"

Object.Instantiate<T>(T, Transform)"

Object.Instantiate<T>(T, Transform, Boolean)"

Object.Destroy(Object, Single)

Object.Destroy(Object)

Object.DestroyImmediate(Object, Boolean)

Object.DestroyImmediate(Object)

Object.FindObjectsOfType(Type)

Object.DontDestroyOnLoad(Object)

Object.DestroyObject(Object, Single)

Object.DestroyObject(Object)

Object.FindSceneObjectsOfType(Type)

Object.FindObjectsOfTypeIncludingAssets(Type)

Object.FindObjectsOfType<T>()

Object.FindObjectOfType<T>()

Object.FindObjectsOfTypeAll(Type)

Object.FindObjectOfType(Type)

Object.ToString()

Object.name

Object.hideFlags

Object.Equals(Object, Object)

Object.GetType()

Object.MemberwiseClone()

Object.ReferenceEquals(Object, Object)

Namespace: System.Dynamic.ExpandoObject#
Assembly: MLAPI.dll#
Syntax#
[AddComponentMenu("MLAPI/NetworkObject", -99)]
[DisallowMultipleComponent]
public sealed class NetworkObject : MonoBehaviour

Fields#

AlwaysReplicateAsRoot#

If true, the object will always be replicated as root on clients and the parent will be ignored.

Declaration#

public bool AlwaysReplicateAsRoot

Field Value#

TypeDescription
System.Boolean

CheckObjectVisibility#

Delegate invoked when the MLAPI needs to know if the object should be visible to a client, if null it will assume true

Declaration#

public NetworkObject.VisibilityDelegate CheckObjectVisibility

Field Value#

TypeDescription
NetworkObject.VisibilityDelegate

DontDestroyWithOwner#

Whether or not to destroy this object if it's owner is destroyed. If false, the objects ownership will be given to the server.

Declaration#

public bool DontDestroyWithOwner

Field Value#

TypeDescription
System.Boolean

IncludeTransformWhenSpawning#

Delegate invoked when the MLAPI needs to know if it should include the transform when spawning the object, if null it will assume true

Declaration#

public NetworkObject.SpawnDelegate IncludeTransformWhenSpawning

Field Value#

TypeDescription
NetworkObject.SpawnDelegate

NetworkInstanceId#

InstanceId is the id that is unique to the object and scene for a scene object when UsePrefabSync is false. If UsePrefabSync is true or if it's used on non scene objects, this has no effect. Should not be set manually

Declaration#

[HideInInspector]
[SerializeField]
public ulong NetworkInstanceId

Field Value#

TypeDescription
System.UInt64

PrefabHash#

The Prefab unique hash. This should not be set my the user but rather changed by editing the PrefabHashGenerator. It has to be the same for all instances of a prefab

Declaration#

[HideInInspector]
[SerializeField]
public ulong PrefabHash

Field Value#

TypeDescription
System.UInt64

PrefabHashGenerator#

The generator used to change the PrefabHash. This should be set the same for all instances of a prefab. It has to be unique in relation to other prefabs

Declaration#

[SerializeField]
public string PrefabHashGenerator

Field Value#

TypeDescription
System.String

Properties#

DestroyWithScene#

Gets whether or not the object should be automatically removed when the scene is unloaded.

Declaration#

public bool DestroyWithScene { get; }

Property Value#

TypeDescription
System.Boolean

IsLocalPlayer#

Gets if the object is the the personal clients player object

Declaration#

public bool IsLocalPlayer { get; }

Property Value#

TypeDescription
System.Boolean

IsOwnedByServer#

Gets Whether or not the object is owned by anyone

Declaration#

public bool IsOwnedByServer { get; }

Property Value#

TypeDescription
System.Boolean

IsOwner#

Gets if the object is owned by the local player or if the object is the local player object

Declaration#

public bool IsOwner { get; }

Property Value#

TypeDescription
System.Boolean

IsPlayerObject#

Gets if this object is a player object

Declaration#

public bool IsPlayerObject { get; }

Property Value#

TypeDescription
System.Boolean

IsSceneObject#

Gets if the object is a SceneObject, null if it's not yet spawned but is a scene object.

Declaration#

public bool? IsSceneObject { get; }

Property Value#

TypeDescription
System.Nullable<System.Boolean>

IsSpawned#

Gets if the object has yet been spawned across the network

Declaration#

public bool IsSpawned { get; }

Property Value#

TypeDescription
System.Boolean

NetworkManager#

Gets the NetworkManager that owns this NetworkObject instance

Declaration#

public NetworkManager NetworkManager { get; }

Property Value#

TypeDescription
NetworkManager

NetworkObjectId#

Gets the unique Id of this object that is synced across the network

Declaration#

public ulong NetworkObjectId { get; }

Property Value#

TypeDescription
System.UInt64

OwnerClientId#

Gets the ClientId of the owner of this NetworkObject

Declaration#

public ulong OwnerClientId { get; }

Property Value#

TypeDescription
System.UInt64

Methods#

ChangeOwnership(UInt64)#

Changes the owner of the object. Can only be called from server

Declaration#

public void ChangeOwnership(ulong newOwnerClientId)

Parameters#

TypeNameDescription
System.UInt64newOwnerClientIdThe new owner clientId

Despawn(Boolean)#

Despawns this GameObject and destroys it for other clients. This should be used if the object should be kept on the server

Declaration#

public void Despawn(bool destroy = false)

Parameters#

TypeNameDescription
System.Booleandestroy

GetObservers()#

Returns Observers enumerator

Declaration#

public HashSet<ulong>.Enumerator GetObservers()

Returns#

TypeDescription
System.Collections.Generic.HashSet.Enumerator<>Observers enumerator

IsNetworkVisibleTo(UInt64)#

Whether or not this object is visible to a specific client

Declaration#

public bool IsNetworkVisibleTo(ulong clientId)

Parameters#

TypeNameDescription
System.UInt64clientIdThe clientId of the client

Returns#

TypeDescription
System.BooleanTrue if the client knows about the object

NetworkHide(List<NetworkObject>, UInt64)#

Hides a list of objects from a client

Declaration#

public static void NetworkHide(List<NetworkObject> networkObjects, ulong clientId)

Parameters#

TypeNameDescription
System.Collections.Generic.List<NetworkObject>networkObjectsThe objects to hide
System.UInt64clientIdThe client to hide the objects from

NetworkHide(UInt64)#

Hides a object from a specific client

Declaration#

public void NetworkHide(ulong clientId)

Parameters#

TypeNameDescription
System.UInt64clientIdThe client to hide the object for

NetworkShow(List<NetworkObject>, UInt64, Stream)#

Shows a list of previously hidden objects to a client

Declaration#

public static void NetworkShow(List<NetworkObject> networkObjects, ulong clientId, Stream payload = null)

Parameters#

TypeNameDescription
System.Collections.Generic.List<NetworkObject>networkObjectsThe objects to show
System.UInt64clientIdThe client to show the objects to
System.IO.StreampayloadAn optional payload to send as part of the spawns

NetworkShow(UInt64, Stream)#

Shows a previously hidden object to a client

Declaration#

public void NetworkShow(ulong clientId, Stream payload = null)

Parameters#

TypeNameDescription
System.UInt64clientIdThe client to show the object to
System.IO.StreampayloadAn optional payload to send as part of the spawn

RemoveOwnership()#

Removes all ownership of an object from any client. Can only be called from server

Declaration#

public void RemoveOwnership()

Spawn(Stream, Boolean)#

Spawns this GameObject across the network. Can only be called from the Server

Declaration#

public void Spawn(Stream spawnPayload = null, bool destroyWithScene = false)

Parameters#

TypeNameDescription
System.IO.StreamspawnPayloadThe writer containing the spawn payload
System.BooleandestroyWithSceneShould the object be destroyd when the scene is changed

SpawnAsPlayerObject(UInt64, Stream, Boolean)#

Spawns an object across the network and makes it the player object for the given client

Declaration#

public void SpawnAsPlayerObject(ulong clientId, Stream spawnPayload = null, bool destroyWithScene = false)

Parameters#

TypeNameDescription
System.UInt64clientIdThe clientId whos player object this is
System.IO.StreamspawnPayloadThe writer containing the spawn payload
System.BooleandestroyWithSceneShould the object be destroyd when the scene is changed

SpawnWithOwnership(UInt64, Stream, Boolean)#

Spawns an object across the network with a given owner. Can only be called from server

Declaration#

public void SpawnWithOwnership(ulong clientId, Stream spawnPayload = null, bool destroyWithScene = false)

Parameters#

TypeNameDescription
System.UInt64clientIdThe clientId to own the object
System.IO.StreamspawnPayloadThe writer containing the spawn payload
System.BooleandestroyWithSceneShould the object be destroyd when the scene is changed