using System.Collections; using System.Collections.Generic; using UnityEngine; public class ServerData { public string serverName;//服务器的名字 public string ipStr;//服务器地址 public int port;//端口号 public ServerType serverType;// 学校自己的服务器 还是 } public enum ServerType { Public, Private, } public class GameServerInfo { private static GameServerInfo _instance; public static GameServerInfo Instance { get { if (_instance == null) { _instance = new GameServerInfo(); } return _instance; } } public ServerData CurServer; public List servers; private GameServerInfo() { servers = new List(); } //初始化服务器列表 public void InitServerInfo() { servers.Clear();//先清空原有的服务器数据 } public void AddServer(string serverName, string ipStr, int port, ServerType serverType) { ServerData data = new ServerData(); data.serverName = serverName; data.serverType = serverType; data.ipStr = ipStr; data.port = port; servers.Add(data); } }