docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetcodeIntegrationTestHelpers

    Provides helpers for running multi instance tests.

    Inheritance
    object
    NetcodeIntegrationTestHelpers
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Unity.Netcode.TestHelpers.Runtime
    Assembly: solution.dll
    Syntax
    public static class NetcodeIntegrationTestHelpers

    Fields

    Name Description
    DefaultMinFrames
    DefaultTimeout

    Properties

    Name Description
    IsNetcodeIntegrationTestRunning
    NetworkManagerInstances

    Methods

    Name Description
    CleanUpHandlers()

    Call this to clean up the IntegrationTestSceneHandler and destroy the s_CoroutineRunner. Note: If deriving from NetcodeIntegrationTest or using Destroy() then you typically won't need to do this.

    Create(int, out NetworkManager, out NetworkManager[], int, bool, bool)

    Creates NetworkingManagers and configures them for use in a multi instance setting.

    CreateNetworkObjectPrefab(string, NetworkManager, params NetworkManager[])
    CreateNewClients(int, out NetworkManager[], bool)

    Used to add a client to the already existing list of clients

    CreateServer(bool)
    Destroy()

    Should always be invoked when finished with a single unit test (i.e. during TearDown)

    GetGlobalObjectIdHash(NetworkObject)
    GetNetworkObjectByRepresentation(Func<NetworkObject, bool>, NetworkManager, ResultWrapper<NetworkObject>, bool, float)

    Gets a NetworkObject instance as it's represented by a certain peer.

    GetNetworkObjectByRepresentation(ulong, NetworkManager, ResultWrapper<NetworkObject>, bool, float)

    Gets a NetworkObject instance as it's represented by a certain peer.

    GetNetworkObjectByRepresentationWithTimeTravel(Func<NetworkObject, bool>, NetworkManager, ResultWrapper<NetworkObject>, bool, int)

    Gets a NetworkObject instance as it's represented by a certain peer.

    GetNextGlobalIdHashValue()
    MakeNetworkObjectTestPrefab(NetworkObject, uint)

    Normally we would only allow player prefabs to be set to a prefab. Not runtime created objects. In order to prevent having a Resource folder full of a TON of prefabs that we have to maintain, MultiInstanceHelper has a helper function that lets you mark a runtime created object to be treated as a prefab by the Netcode. That's how we can get away with creating the player prefab at runtime without it being treated as a SceneObject or causing other conflicts with the Netcode.

    MarkAsSceneObjectRoot(GameObject, NetworkManager, NetworkManager[])
    RegisterHandlers(NetworkManager, bool)

    Call this to register scene validation and the IntegrationTestSceneHandler Note: If deriving from NetcodeIntegrationTest or using Destroy() then you typically won't need to call this.

    RegisterNetcodeIntegrationTest(bool)
    Start(bool, NetworkManager, NetworkManager[], BeforeClientStartCallback)

    Starts NetworkManager instances created by the Create method.

    StartOneClient(NetworkManager)

    Starts one single client and makes sure to register the required hooks and handlers

    StopOneClient(NetworkManager, bool)

    Stops one single client and makes sure to cleanup any static variables in this helper

    WaitForClientConnected(NetworkManager, ResultWrapper<bool>, float)

    Waits on the client side to be connected.

    WaitForClientConnectedToServer(NetworkManager, ResultWrapper<bool>, float)

    Waits on the server side for 1 client to be connected

    WaitForClientsConnected(NetworkManager[], ResultWrapper<bool>, float)
    WaitForClientsConnectedToServer(NetworkManager, int, ResultWrapper<bool>, float)

    Waits on the server side for 1 client to be connected

    WaitForCondition(Func<bool>, ResultWrapper<bool>, float, int)

    Waits for a predicate condition to be met

    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)