docs.unity.cn
    Show / Hide Table of Contents

    Class DefaultDriverBuilder

    Default helper method implementation for constructing NetworkDriverStore.NetworkDriverInstance, default NetworkSettings and registering these on the NetworkDriverStore.

    Inheritance
    Object
    DefaultDriverBuilder
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.NetCode
    Syntax
    public static class DefaultDriverBuilder

    Properties

    DefaultDriverConstructor

    Return an instance of the IPCAndSocketDriverConstructor constructor

    Declaration
    public static INetworkStreamDriverConstructor DefaultDriverConstructor { get; }
    Property Value
    Type Description
    INetworkStreamDriverConstructor

    Methods

    ClientUseSocketDriver(NetDebug)

    Helper method to determine if the client world should prefer using a socket-based network interface (UDP or WebSocket) or the IPCNetworkInterface. IPC connection type is preferred only in case the RequestedPlayType is set to client/server mode, a server world exist in the process and the Unity.NetCode.NetworkSimulatorSettings are disable (in the editor or development build).

    Declaration
    public static bool ClientUseSocketDriver(NetDebug netDebug)
    Parameters
    Type Name Description
    NetDebug netDebug
    Returns
    Type Description
    Boolean

    True when a client world should use a network driver which implements a socket based interface.

    Remarks

    This method should not be used to configure server driver. Also, for server build, this method always return true.

    CreateClientNetworkDriver<T>(T)

    Helper method for creating NetworkDriver suitable for client. The driver will use the the specified netIf and is configured using the internal defaults. See: GetNetworkSettings().

    Declaration
    public static NetworkDriverStore.NetworkDriverInstance CreateClientNetworkDriver<T>(T netIf)
        where T : struct, INetworkInterface
    Parameters
    Type Name Description
    T netIf

    the instance of a INetworkInterface to use to create the driver

    Returns
    Type Description
    NetworkDriverStore.NetworkDriverInstance

    A new NetworkDriverStore.NetworkDriverInstance

    Type Parameters
    Name Description
    T

    the INetworkInterface type ot use

    CreateClientNetworkDriver<T>(T, NetworkSettings)

    Helper method for creating NetworkDriver suitable for client. The driver will use the specified INetworkInterface and is configured using the provided settings.

    Declaration
    public static NetworkDriverStore.NetworkDriverInstance CreateClientNetworkDriver<T>(T netIf, NetworkSettings settings)
        where T : struct, INetworkInterface
    Parameters
    Type Name Description
    T netIf

    the instance of a INetworkInterface to use to create the driver

    NetworkSettings settings

    A list of the parameters that describe the network configuration.

    Returns
    Type Description
    NetworkDriverStore.NetworkDriverInstance

    A new NetworkDriverStore.NetworkDriverInstance

    Type Parameters
    Name Description
    T

    the INetworkInterface type ot use

    CreateClientPipelines(ref NetworkDriverStore.NetworkDriverInstance)

    Create the default network pipelines (reliable, unreliable, unreliable fragmented) for the client.

    Declaration
    public static void CreateClientPipelines(ref NetworkDriverStore.NetworkDriverInstance driverInstance)
    Parameters
    Type Name Description
    NetworkDriverStore.NetworkDriverInstance driverInstance

    The NetworkDriverStore.NetworkDriverInstance instance to configure

    CreateServerNetworkDriver<T>(T, Int32)

    Helper method for creating server NetworkDriver given the specified netIf The driver is configured with the internal defaults. See: GetNetworkServerSettings(Int32).

    Declaration
    public static NetworkDriverStore.NetworkDriverInstance CreateServerNetworkDriver<T>(T netIf, int playerCount = 0)
        where T : struct, INetworkInterface
    Parameters
    Type Name Description
    T netIf

    the instance of a INetworkInterface to use to create the driver

    Int32 playerCount

    Amount of players the server should allocate receive and send queue for. The estimation is that each player will receive 4 packets.

    Returns
    Type Description
    NetworkDriverStore.NetworkDriverInstance

    A new NetworkDriverStore.NetworkDriverInstance

    Type Parameters
    Name Description
    T

    the INetworkInterface type ot use

    CreateServerNetworkDriver<T>(T, NetworkSettings)

    Helper method for creating server NetworkDriver given the specified INetworkInterface The driver is configured using the NetworkSettings.

    Declaration
    public static NetworkDriverStore.NetworkDriverInstance CreateServerNetworkDriver<T>(T netIf, NetworkSettings settings)
        where T : struct, INetworkInterface
    Parameters
    Type Name Description
    T netIf
    NetworkSettings settings

    A list of the parameters that describe the network configuration.

    Returns
    Type Description
    NetworkDriverStore.NetworkDriverInstance

    A new NetworkDriverStore.NetworkDriverInstance

    Type Parameters
    Name Description
    T

    the INetworkInterface type ot use

    CreateServerPipelines(ref NetworkDriverStore.NetworkDriverInstance)

    Create the default network pipelines (reliable, unreliable, unreliable fragmented) for the server.

    Declaration
    public static void CreateServerPipelines(ref NetworkDriverStore.NetworkDriverInstance driverInstance)
    Parameters
    Type Name Description
    NetworkDriverStore.NetworkDriverInstance driverInstance

    The NetworkDriverStore.NetworkDriverInstance instance to configure

    GetNetworkServerSettings(Int32)

    Return a set of internal default settings. This will use the NetworkSimulator parameters set by PlayMode Tools.

    Declaration
    public static NetworkSettings GetNetworkServerSettings(int playerCount = 0)
    Parameters
    Type Name Description
    Int32 playerCount

    Amount of players the server should allocate receive and send queue for. The estimation is that each player will receive 4 packets.

    Returns
    Type Description
    NetworkSettings

    Parameters that describe the network configuration.

    GetNetworkSettings()

    Return a set of internal default settings. This will use the NetworkSimulator parameters set by PlayMode Tools.

    Declaration
    public static NetworkSettings GetNetworkSettings()
    Returns
    Type Description
    NetworkSettings

    A new NetworkDriverStore.NetworkDriverInstance

    RegisterClientDriver(World, ref NetworkDriverStore, NetDebug)

    Register a NetworkDriver instance in the driverStore that uses either:

      These are configured using internal defaults. See: GetNetworkSettings().

      Declaration
      public static void RegisterClientDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug)
      Parameters
      Type Name Description
      World world

      Used for determining whether we are running in a client or server world.

      NetworkDriverStore driverStore

      Store for NetworkDriver.

      NetDebug netDebug

      For handling logging.

      RegisterClientDriver(World, ref NetworkDriverStore, NetDebug, NetworkSettings)

      Register a NetworkDriver instance in the driverStore that uses either:

        These are configured using the NetworkSettings passed in.

        Declaration
        public static void RegisterClientDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, NetworkSettings settings)
        Parameters
        Type Name Description
        World world

        Used for determining whether we are running in a client or server world.

        NetworkDriverStore driverStore

        Store for NetworkDriver.

        NetDebug netDebug

        For handling logging.

        NetworkSettings settings

        A list of the parameters that describe the network configuration.

        RegisterClientDriver(World, ref NetworkDriverStore, NetDebug, ref RelayServerData)

        Register a NetworkDriver instance in and stores it in driverStore:

        • a single IPCNetworkInterface NetworkDriver if the both client and server worlds are present in the same process.
        • a single UDPNetworkInterface driver in all other cases.
          These are configured using the default settings. See GetNetworkSettings().
        Declaration
        public static void RegisterClientDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, ref RelayServerData relayData)
        Parameters
        Type Name Description
        World world

        Used for determining whether we are running in a client or server world.

        NetworkDriverStore driverStore

        Store for NetworkDriver.

        NetDebug netDebug

        For handling logging.

        RelayServerData relayData

        Server information to make a connection using a relay server.

        RegisterClientIpcDriver(World, ref NetworkDriverStore, NetDebug, NetworkSettings)

        Register an IPCNetworkInterface NetworkDriver instance in driverStore. This are configured using the NetworkSettings passed in.

        Declaration
        public static void RegisterClientIpcDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, NetworkSettings settings)
        Parameters
        Type Name Description
        World world

        Used for determining whether we are running in a client or server world.

        NetworkDriverStore driverStore

        Store for NetworkDriver.

        NetDebug netDebug

        For handling logging.

        NetworkSettings settings

        A list of the parameters that describe the network configuration.

        RegisterClientUdpDriver(World, ref NetworkDriverStore, NetDebug, NetworkSettings)

        Register a UDPNetworkInterface NetworkDriver instance in driverStore. This are configured using the NetworkSettings passed in.

        Declaration
        public static void RegisterClientUdpDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, NetworkSettings settings)
        Parameters
        Type Name Description
        World world

        Used for determining whether we are running in a client or server world.

        NetworkDriverStore driverStore

        Store for NetworkDriver.

        NetDebug netDebug

        For handling logging.

        NetworkSettings settings

        A list of the parameters that describe the network configuration.

        RegisterClientWebSocketDriver(World, ref NetworkDriverStore, NetDebug, NetworkSettings)

        Register a WebSocketNetworkInterface NetworkDriver instance in driverStore. This are configured using the NetworkSettings passed in. The constructed driver does not use a reliable pipeline stage (websocket are already reliable) and the reliablePipeline instance is a NullPipelineStage.

        Declaration
        public static void RegisterClientWebSocketDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, NetworkSettings settings)
        Parameters
        Type Name Description
        World world

        Used for determining whether we are running in a client or server world.

        NetworkDriverStore driverStore

        Store for NetworkDriver.

        NetDebug netDebug

        For handling logging.

        NetworkSettings settings

        A list of the parameters that describe the network configuration.

        RegisterServerDriver(World, ref NetworkDriverStore, NetDebug, Int32)

        Register multiple NetworkDriver instances to the driverStore that uses different INetworkInterface:

          These are configured using internal defaults. See: GetNetworkSettings().

          Declaration
          public static void RegisterServerDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, int playerCount = 0)
          Parameters
          Type Name Description
          World world

          Used for determining whether we are running in a client or server world.

          NetworkDriverStore driverStore

          Store for NetworkDriver.

          NetDebug netDebug

          For handling logging.

          Int32 playerCount

          Amount of players the server should allocate receive and send queue for. The estimation is that each player will receive 4 packets.

          RegisterServerDriver(World, ref NetworkDriverStore, NetDebug, NetworkSettings)

          Register a multiple NetworkDriver instances to hte driverStore:

            These drivers are configured using the NetworkSettings passed in.

            Declaration
            public static void RegisterServerDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, NetworkSettings settings)
            Parameters
            Type Name Description
            World world

            Used for determining whether we are running in a client or server world.

            NetworkDriverStore driverStore

            Store for NetworkDriver.

            NetDebug netDebug

            For handling logging.

            NetworkSettings settings

            A list of the parameters that describe the network configuration.

            Remarks

            Not available for WebGL builds. Always available in the Editor.

            RegisterServerDriver(World, ref NetworkDriverStore, NetDebug, ref RelayServerData, Int32)

            Register multiple NetworkDriver instances to the driverStore that uses different INetworkInterface:

              These are configured using internal defaults. See: GetNetworkSettings().

              Declaration
              public static void RegisterServerDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, ref RelayServerData relayData, int playerCount = 0)
              Parameters
              Type Name Description
              World world

              Used for determining whether we are running in a client or server world.

              NetworkDriverStore driverStore

              Store for NetworkDriver.

              NetDebug netDebug

              For handling logging.

              RelayServerData relayData

              Server information to make a connection using a relay server.

              Int32 playerCount

              Amount of players the server should allocate receive and send queue for. The estimation is that each player will receive 4 packets.

              Remarks

              Not available for WebGL builds. Always available in the Editor.

              RegisterServerIpcDriver(World, ref NetworkDriverStore, NetDebug, NetworkSettings)

              Register a IPCNetworkInterface NetworkDriver instance in driverStore. This are configured using the NetworkSettings passed in.

              If the requested ClientServerBootstrap.PlayType is Server this will do nothing as no local clients will ever make use of the IPC mechanism.

              Declaration
              public static void RegisterServerIpcDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, NetworkSettings settings)
              Parameters
              Type Name Description
              World world

              Used for determining whether we are running in a client or server world.

              NetworkDriverStore driverStore

              Store for NetworkDriver.

              NetDebug netDebug

              For handling logging.

              NetworkSettings settings

              A list of the parameters that describe the network configuration.

              Remarks

              Not available for WebGL builds. Always available in the Editor.

              RegisterServerUdpDriver(World, ref NetworkDriverStore, NetDebug, NetworkSettings)

              Register a UDPNetworkInterface NetworkDriver instance in driverStore. This are configured using the NetworkSettings passed in.

              Declaration
              public static void RegisterServerUdpDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, NetworkSettings settings)
              Parameters
              Type Name Description
              World world

              Used for determining whether we are running in a client or server world.

              NetworkDriverStore driverStore

              Store for NetworkDriver.

              NetDebug netDebug

              For handling logging.

              NetworkSettings settings

              A list of the parameters that describe the network configuration.

              Remarks

              Not available for WebGL builds. Always available in the Editor.

              RegisterServerWebSocketDriver(World, ref NetworkDriverStore, NetDebug, NetworkSettings)

              Register a WebSocketNetworkInterface NetworkDriver instance in driverStore. This are configured using the NetworkSettings passed in. The constructed driver does not use a reliable pipeline stage (websocket are already reliable) and the reliablePipeline instance is a NullPipelineStage.

              Declaration
              public static void RegisterServerWebSocketDriver(World world, ref NetworkDriverStore driverStore, NetDebug netDebug, NetworkSettings settings)
              Parameters
              Type Name Description
              World world

              Used for determining whether we are running in a client or server world.

              NetworkDriverStore driverStore

              Store for NetworkDriver.

              NetDebug netDebug

              For handling logging.

              NetworkSettings settings

              A list of the parameters that describe the network configuration.

              Remarks

              Not available for WebGL build. Always available in the Editor.

              Back to top Copyright © 2023 Unity Technologies — Terms of use
              Generated by DocFX
              on Wednesday, September 20, 2023