docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class AutomaticThinClientWorldsUtility

    Have netcode automatically manage thin clients for you by assigning NumThinClientsRequested.

    Inheritance
    object
    AutomaticThinClientWorldsUtility
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.NetCode
    Assembly: Unity.NetCode.dll
    Syntax
    public class AutomaticThinClientWorldsUtility

    Fields

    BootstrapInitialization

    If your automatic thin clients need custom initialization during bootstrap (e.g. due to custom scene management settings), modify this delegate. Uses DefaultBootstrapThinClientWorldInitialization(World) by default. Set to null to disable the bootstrap initialization feature.

    Declaration
    public static AutomaticThinClientWorldsUtility.ThinClientWorldInitializationDelegate BootstrapInitialization
    Field Value
    Type Description
    AutomaticThinClientWorldsUtility.ThinClientWorldInitializationDelegate

    CreationFrequency

    The frequency with which we should create the thin client worlds (in hertz i.e. worlds per second). 0 denotes 'create all immediately'. If null (the default), it'll use ThinClientCreationFrequency in the editor, else 0.

    Declaration
    public static float? CreationFrequency
    Field Value
    Type Description
    float?

    NumThinClientsRequested

    Set the desired number of thin client worlds.

    Declaration
    public static int? NumThinClientsRequested
    Field Value
    Type Description
    int?
    Remarks

    If null (the default), it'll use RequestedNumThinClients in the editor, else 0. Worlds are only created in builds if you hook up UpdateAutomaticThinClientWorlds().

    ReferenceWorld

    The world to use for data injection (like to know which sub-scene(s) to load). If null, we'll try to use any existing client or server worlds, found via ClientWorld etc.

    Declaration
    public static World ReferenceWorld
    Field Value
    Type Description
    World

    RuntimeInitialization

    If your automatic thin clients need custom initialization at runtime (e.g. due to custom scene management settings), modify this delegate. Uses DefaultRuntimeThinClientWorldInitialization(World) by default. Set to null to disable the runtime initialization feature.

    Declaration
    public static AutomaticThinClientWorldsUtility.ThinClientWorldInitializationDelegate RuntimeInitialization
    Field Value
    Type Description
    AutomaticThinClientWorldsUtility.ThinClientWorldInitializationDelegate

    Properties

    AutomaticallyManagedWorlds

    A list of all thin client worlds created by (and managed by) the netcode package itself. If you add a thin client to this list, netcode will take ownership of it. This list prevents the netcode package from deleting your thin client worlds.

    Declaration
    public static List<World> AutomaticallyManagedWorlds { get; }
    Property Value
    Type Description
    List<World>

    IsBootstrapInitializationEnabled

    Denotes if automatic bootstrap thin client creation is enabled.

    Declaration
    public static bool IsBootstrapInitializationEnabled { get; }
    Property Value
    Type Description
    bool

    IsRuntimeInitializationEnabled

    Denotes if automatic RUNTIME thin client creation is enabled.

    Declaration
    public static bool IsRuntimeInitializationEnabled { get; }
    Property Value
    Type Description
    bool

    Methods

    BootstrapThinClientWorlds()

    Use this method when inside the Initialize(string) flow.

    Declaration
    public static void BootstrapThinClientWorlds()
    Remarks

    This has to exist because Entities/Netcode uses a fast-path, where it loads the entity scene data (for all loaded scenes) once, and then auto-injects said data into all appropriate bootstrapping worlds.

    CleanupWorlds()

    Utility to remove all stale worlds from the list.

    Declaration
    public static int CleanupWorlds()
    Returns
    Type Description
    int

    Num removed.

    DefaultBootstrapThinClientWorldInitialization(World)

    By default, thin clients created during the bootstrap will automatically be injected with the loaded scenes sub-scenes. Thus, we do not need to do anything custom.

    Declaration
    public static World DefaultBootstrapThinClientWorldInitialization(World referenceWorld)
    Parameters
    Type Name Description
    World referenceWorld

    The world to reference when creating this one (for the purposes of scene loading etc.).

    Returns
    Type Description
    World

    The newly created world, otherwise null.

    DefaultRuntimeThinClientWorldInitialization(World)

    If your automatic thin clients need custom initialization at runtime (e.g. due to custom scene management settings), modify this delegate. Uses DefaultRuntimeThinClientWorldInitialization(World) by default. Set to null to disable the runtime initialization feature.

    Declaration
    public static World DefaultRuntimeThinClientWorldInitialization(World referenceWorld)
    Parameters
    Type Name Description
    World referenceWorld

    The world to reference when creating this one (for the purposes of scene loading etc.).

    Returns
    Type Description
    World

    The newly created world, otherwise null.

    UpdateAutomaticThinClientWorlds()

    If you use this feature, call this method in a UnityEngine.MonoBehaviour Update method. It'll apply the current configured values.

    Declaration
    public static bool UpdateAutomaticThinClientWorlds()
    Returns
    Type Description
    bool

    True if any worlds were created or destroyed.

    UpdateAutomaticThinClientWorldsImmediate(World, int, int, out bool)

    Creates and/or Disposes thin client worlds until the final count is equal to targetThinClientCount.

    Declaration
    public static NativeList<WorldUnmanaged> UpdateAutomaticThinClientWorldsImmediate(World referenceWorld, int targetThinClientCount, int maxAllowedSpawn, out bool didCreateOrDestroy)
    Parameters
    Type Name Description
    World referenceWorld

    The desired world to use as a reference. If null, we'll try to use any existing client or server worlds.

    int targetThinClientCount

    The desired final count of thin clients.

    int maxAllowedSpawn

    Rate limiting feature. Worlds are disposed immediately, but only instantiated at this frequency.

    bool didCreateOrDestroy

    True if worlds were created or destroyed.

    Returns
    Type Description
    NativeList<WorldUnmanaged>

    The list of successfully created worlds, otherwise default.

    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)