using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; namespace Multiplayer { public class ServerManager : MonoBehaviour { [SerializeField] private bool StartOnAwake = true; [SerializeField] private int Port = 4444; public Dictionary AllPlayers; public NetworkServerSimple Server { get; private set; } private LoginManager loginManager; private void Start() { if (StartOnAwake) StartServer(); } [ContextMenu("Start Server")] public void StartServer() { StartServer(Port); } public void StartServer(int Port) { this.Port = Port; AllPlayers = new Dictionary(); Server = new NetworkServerSimple(); Server.Configure(ChannelConfig.DefaultTopology()); Debug.Log("Starting Server on " + Port); loginManager = new LoginManager(this); Server.Listen(Port); } private void Update() { if (Server != null) Server.Update(); } } }