docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetworkPrefaInstanceHandler

    The Prefab instance handler to use for this test

    Inheritance
    object
    NetworkPrefaInstanceHandler
    Implements
    INetworkPrefabInstanceHandler
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Netcode.RuntimeTests
    Assembly: Unity.Netcode.RuntimeTests.dll
    Syntax
    public class NetworkPrefaInstanceHandler : INetworkPrefabInstanceHandler

    Constructors

    NetworkPrefaInstanceHandler(NetworkObject)

    Declaration
    public NetworkPrefaInstanceHandler(NetworkObject networkObject)
    Parameters
    Type Name Description
    NetworkObject networkObject

    Methods

    Destroy(NetworkObject)

    Invoked on Client and Server Once an implementation is registered with the NetworkPrefabHandler, this method will be called when a Network Prefab associated NetworkObject is:

    Server Side: destroyed or despawned with the destroy parameter equal to true If Despawn(bool) is invoked with the default destroy parameter (i.e. false) then this method will NOT be invoked!

    Client Side: destroyed when the client receives a destroy object message from the server or host.

    Note on Pooling: When this method is invoked, you do not need to destroy the NetworkObject as long as you want your pool to persist. The most common approach is to make the NetworkObject inactive by calling SetActive(bool).

    Declaration
    public void Destroy(NetworkObject networkObject)
    Parameters
    Type Name Description
    NetworkObject networkObject

    The NetworkObject being destroyed

    Instantiate(ulong, Vector3, Quaternion)

    Client Side Only Once an implementation is registered with the NetworkPrefabHandler, this method will be called every time a Network Prefab associated NetworkObject is spawned on clients

    Note On Hosts: Use the RegisterHostGlobalObjectIdHashValues(GameObject, List<GameObject>) method to register all targeted NetworkPrefab overrides manually since the host will be acting as both a server and client.

    Note on Pooling: If you are using a NetworkObject pool, don't forget to make the NetworkObject active via the SetActive(bool) method.

    Declaration
    public NetworkObject Instantiate(ulong ownerClientId, Vector3 position, Quaternion rotation)
    Parameters
    Type Name Description
    ulong ownerClientId

    the owner for the NetworkObject to be instantiated

    Vector3 position

    the initial/default position for the NetworkObject to be instantiated

    Quaternion rotation

    the initial/default rotation for the NetworkObject to be instantiated

    Returns
    Type Description
    NetworkObject

    StillHasInstances()

    Declaration
    public bool StillHasInstances()
    Returns
    Type Description
    bool

    Implements

    INetworkPrefabInstanceHandler
    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)