Add [Obsolete] for compatibility

This commit is contained in:
vis2k 2019-03-25 16:59:17 +01:00
parent 9bc1dc1e85
commit 1879f5ecdc
2 changed files with 12 additions and 1 deletions

View File

@ -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<NetworkClient> allClients => new List<NetworkClient>{singleton};
public static readonly Dictionary<int, NetworkMessageDelegate> handlers = new Dictionary<int, NetworkMessageDelegate>();
public static NetworkConnection connection { get; internal set; }

View File

@ -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() {}