diff --git a/Assets/Mirror/Runtime/NetworkClient.cs b/Assets/Mirror/Runtime/NetworkClient.cs index c30e1d716..e75747f15 100644 --- a/Assets/Mirror/Runtime/NetworkClient.cs +++ b/Assets/Mirror/Runtime/NetworkClient.cs @@ -12,8 +12,15 @@ public enum ConnectState Disconnected } - public static class NetworkClient + // TODO make fully static after removing obsoleted singleton! + public class NetworkClient { + [Obsolete("Use NetworkClient directly. Singleton isn't needed anymore, all functions are static now. For example: NetworkClient.Send(message) instead of NetworkClient.singleton.Send(message).")] + public static NetworkClient singleton = new NetworkClient(); + + [Obsolete("Use NetworkClient.singleton instead. There is always exactly one client.")] + public static List allClients => new List{singleton}; + public static readonly Dictionary handlers = new Dictionary(); public static NetworkConnection connection { get; internal set; } diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 4980286ac..d7a5c0384 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -61,6 +61,8 @@ public class NetworkManager : MonoBehaviour public static string networkSceneName = ""; [NonSerialized] public bool isNetworkActive; + [Obsolete("Use NetworkClient directly, it will be made static soon. For example, use NetworkClient.Send(message) instead of NetworkManager.client.Send(message)")] + public NetworkClient client => NetworkClient.singleton; static int s_StartPositionIndex; public static NetworkManager singleton; @@ -791,6 +793,8 @@ public virtual void OnClientSceneChanged(NetworkConnection conn) public virtual void OnStartHost() {} public virtual void OnStartServer() {} + [Obsolete("Use OnStartClient() instead of OnStartClient(NetworkClient client). All NetworkClient functions are static now, so you can use NetworkClient.Send(message) instead of client.Send(message) directly now.")] + public virtual void OnStartClient(NetworkClient client) {} public virtual void OnStartClient() {} public virtual void OnStopServer() {} public virtual void OnStopClient() {}