docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetworkVariableBaseInitializesWhenPersisted.PrefabInstanceHandler

    Creates a specified number of instances that persist throughout the entire test session and will only be destroyed/released during the OneTimeTeardown

    Inheritance
    object
    NetworkVariableBaseInitializesWhenPersisted.PrefabInstanceHandler
    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 NetworkVariableBaseInitializesWhenPersisted.PrefabInstanceHandler : INetworkPrefabInstanceHandler

    Constructors

    PrefabInstanceHandler(GameObject)

    Declaration
    public PrefabInstanceHandler(GameObject gameObject)
    Parameters
    Type Name Description
    GameObject gameObject

    Fields

    PrefabInstances

    Declaration
    public Queue<GameObject> PrefabInstances
    Field Value
    Type Description
    Queue<GameObject>

    Methods

    AssignHandler(NetworkManager)

    Invoke when NetworkManagers are created but not started.

    Declaration
    public static void AssignHandler(NetworkManager networkManager)
    Parameters
    Type Name Description
    NetworkManager networkManager

    The NetworkManager instance to assign a handler to. Must not be null and must not already have a handler assigned.

    CleanInstances()

    When we are done with all tests, we finally destroy the persisted objects

    Declaration
    public void CleanInstances()

    DeregisterHandler()

    Declaration
    public void DeregisterHandler()

    Destroy(NetworkObject)

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

    GetInstance()

    Declaration
    public NetworkObject GetInstance()
    Returns
    Type Description
    NetworkObject

    GetInstanceToSpawn(NetworkManager)

    Declaration
    public static NetworkObject GetInstanceToSpawn(NetworkManager networkManager)
    Parameters
    Type Name Description
    NetworkManager networkManager
    Returns
    Type Description
    NetworkObject

    Initialize(NetworkManager)

    Declaration
    public void Initialize(NetworkManager networkManager)
    Parameters
    Type Name Description
    NetworkManager networkManager

    Instantiate(ulong, Vector3, Quaternion)

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

    OneTimeSetup(int, GameObject)

    Declaration
    public static void OneTimeSetup(int numberOfInstances, GameObject prefabInstance)
    Parameters
    Type Name Description
    int numberOfInstances
    GameObject prefabInstance

    ReleaseAll(bool)

    Releases back to the queue and if destroy is true it will completely remove all references so they are cleaned up when

    Declaration
    public static void ReleaseAll(bool destroy = false)
    Parameters
    Type Name Description
    bool destroy

    If true, completely removes all references and cleans up instances. If false, returns handlers to the queue for reuse.

    ValidateInstanceSpawnCount(int)

    This validates that the instances persisted to the next test set and persisted between network sessions

    Declaration
    public bool ValidateInstanceSpawnCount(int minCount)
    Parameters
    Type Name Description
    int minCount
    Returns
    Type Description
    bool

    ValidatePersistedInstances(NetworkManager, int)

    Declaration
    public static bool ValidatePersistedInstances(NetworkManager networkManager, int minCount)
    Parameters
    Type Name Description
    NetworkManager networkManager
    int minCount
    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)