docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetworkSpawnManager

    Class that handles object spawning

    Inheritance
    object
    NetworkSpawnManager
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: MLAPI.Spawning
    Assembly: Unity.Multiplayer.MLAPI.Runtime.dll
    Syntax
    public static class NetworkSpawnManager

    Fields

    SpawnedObjects

    The currently spawned objects

    Declaration
    public static readonly Dictionary<ulong, NetworkObject> SpawnedObjects
    Field Value
    Type Description
    Dictionary<ulong, NetworkObject>

    SpawnedObjectsList

    A list of the spawned objects

    Declaration
    public static readonly HashSet<NetworkObject> SpawnedObjectsList
    Field Value
    Type Description
    HashSet<NetworkObject>

    Methods

    GetLocalPlayerObject()

    Returns the local player object or null if one does not exist

    Declaration
    public static NetworkObject GetLocalPlayerObject()
    Returns
    Type Description
    NetworkObject

    The local player object or null if one does not exist

    GetNetworkPrefabIndexOfHash(ulong)

    Gets the prefab index of a given prefab hash

    Declaration
    public static int GetNetworkPrefabIndexOfHash(ulong hash)
    Parameters
    Type Name Description
    ulong hash

    The hash of the prefab

    Returns
    Type Description
    int

    The index of the prefab

    GetPlayerNetworkObject(ulong)

    Returns the player object with a given clientId or null if one does not exist

    Declaration
    public static NetworkObject GetPlayerNetworkObject(ulong clientId)
    Parameters
    Type Name Description
    ulong clientId
    Returns
    Type Description
    NetworkObject

    The player object with a given clientId or null if one does not exist

    GetPrefabHashFromGenerator(string)

    Returns the prefab hash for a given prefab hash generator

    Declaration
    public static ulong GetPrefabHashFromGenerator(string generator)
    Parameters
    Type Name Description
    string generator

    The prefab hash generator

    Returns
    Type Description
    ulong

    The hash for the given generator

    GetPrefabHashFromIndex(int)

    Returns the prefab hash for the NetworkPrefab with a given index

    Declaration
    public static ulong GetPrefabHashFromIndex(int index)
    Parameters
    Type Name Description
    int index

    The NetworkPrefab index

    Returns
    Type Description
    ulong

    The prefab hash for the given prefab index

    RegisterDestroyHandler(ulong, DestroyHandlerDelegate)

    Registers a delegate for destroying NetworkObjects, useful for object pooling

    Declaration
    public static void RegisterDestroyHandler(ulong prefabHash, NetworkSpawnManager.DestroyHandlerDelegate handler)
    Parameters
    Type Name Description
    ulong prefabHash

    The prefab hash to destroy

    NetworkSpawnManager.DestroyHandlerDelegate handler

    The delegate handler

    RegisterSpawnHandler(ulong, SpawnHandlerDelegate)

    Registers a delegate for spawning NetworkPrefabs, useful for object pooling

    Declaration
    public static void RegisterSpawnHandler(ulong prefabHash, NetworkSpawnManager.SpawnHandlerDelegate handler)
    Parameters
    Type Name Description
    ulong prefabHash

    The prefab hash to spawn

    NetworkSpawnManager.SpawnHandlerDelegate handler

    The delegate handler

    UnregisterDestroyHandler(ulong)

    Unregisters the custom destroy handler for a specific prefab hash

    Declaration
    public static void UnregisterDestroyHandler(ulong prefabHash)
    Parameters
    Type Name Description
    ulong prefabHash

    The prefab hash of the prefab destroy handler that is to be removed

    UnregisterSpawnHandler(ulong)

    Unregisters the custom spawn handler for a specific prefab hash

    Declaration
    public static void UnregisterSpawnHandler(ulong prefabHash)
    Parameters
    Type Name Description
    ulong prefabHash

    The prefab hash of the prefab spawn handler that is to be removed

    In This Article
    Back to top
    Copyright © 2025 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)