docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetworkObject

    A component used to identify that a GameObject in the network

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    NetworkObject
    Inherited Members
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    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.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, 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
    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, bool)
    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, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetType()
    Namespace: Unity.Netcode
    Assembly: solution.dll
    Syntax
    [AddComponentMenu("Netcode/Network Object", -99)]
    [DisallowMultipleComponent]
    public sealed class NetworkObject : MonoBehaviour

    Fields

    Name Description
    ActiveSceneSynchronization

    When set to true and the active scene is changed, this will automatically migrate the NetworkObject into the new active scene on both the server and client instances.

    AlwaysReplicateAsRoot

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

    AutoObjectParentSync

    Whether or not to enable automatic NetworkObject parent synchronization.

    CheckObjectVisibility

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

    DontDestroyWithOwner

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

    IncludeTransformWhenSpawning

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

    OnMigratedToNewScene

    Notifies when the NetworkObject is migrated into a new scene

    SceneMigrationSynchronization

    When enabled (the default), if a NetworkObject is migrated to a different scene (active or not) via MoveGameObjectToScene on the server side all client instances will be synchronized and the NetworkObject migrated into the newly assigned scene. The updated scene migration will get synchronized with late joining clients as well.

    SpawnWithObservers

    When set to false, the NetworkObject will be spawned with no observers initially (other than the server)

    SynchronizeTransform

    Determines if the associated NetworkObject's transform will get synchronized when spawned.

    Properties

    Name Description
    DestroyWithScene

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

    IsLocalPlayer

    Gets if the object is the personal clients player object

    IsOwnedByServer

    Gets Whether or not the object is owned by anyone

    IsOwner

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

    IsPlayerObject

    Gets if this object is a player object

    IsSceneObject

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

    IsSpawned

    Gets if the object has yet been spawned across the network

    NetworkManager

    Gets the NetworkManager that owns this NetworkObject instance

    NetworkObjectId

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

    OwnerClientId

    Gets the ClientId of the owner of this NetworkObject

    PrefabIdHash

    Gets the Prefab Hash Id of this object if the object is registerd as a prefab otherwise it returns 0

    Methods

    Name Description
    ChangeOwnership(ulong)

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

    Despawn(bool)

    Despawns the GameObject of this NetworkObject and sends a destroy message for it to all connected clients.

    GetNetworkBehaviourAtOrderIndex(ushort)
    GetObservers()

    Returns Observers enumerator

    IsNetworkVisibleTo(ulong)

    Whether or not this object is visible to a specific client

    NetworkHide(List<NetworkObject>, ulong)

    Hides a list of NetworkObjects from the targeted client.

    NetworkHide(ulong)

    Hides the NetworkObject from the targeted client.

    NetworkShow(List<NetworkObject>, ulong)

    Makes a list of previously hidden NetworkObjects "netcode visible" for the client specified.

    NetworkShow(ulong)

    Makes the previously hidden NetworkObject "netcode visible" to the targeted client.

    RemoveOwnership()

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

    Spawn(bool)

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

    SpawnAsPlayerObject(ulong, bool)

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

    SpawnWithOwnership(ulong, bool)

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

    TryRemoveParent(bool)

    Removes the parent of the NetworkObject's transform

    TrySetParent(NetworkObject, bool)

    Set the parent of the NetworkObject transform.

    TrySetParent(GameObject, bool)

    Set the parent of the NetworkObject transform.

    TrySetParent(Transform, bool)

    Set the parent of the NetworkObject transform.

    WorldPositionStays()

    Returns the last known cached WorldPositionStays value for this NetworkObject

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)