using System.Collections; using System.Collections.Generic; using UnityEngine; using DevelopEngine; using System; using ETModel; using XFramework; /// /// 空场景游戏入口类 持久化存在 /// public class GameMain : MonoSingleton { public RunState runState = RunState.student; public bool isTest;//测试模式 可跳过某些逻辑 便于测试 //记录UI 控制器 public UIManager UIManager;//当前显示的UI控制器 // Start is called before the first frame update void Start() { Application.runInBackground = true; GameObject.DontDestroyOnLoad(this.gameObject); if (runState == RunState.teacher) { DBManager.Instance.InitDBManager(Application.streamingAssetsPath + "/Config/VirtualRepairSql.db"); TcpServer tcpServer = new TcpServer(); string thisIP = NetHelper.GetAddressIPV4(); tcpServer.Start(thisIP, 8087); SceneSystem.Instance.SetScene(new TeacherScene()); TCPManager.Instance.InitNetWork(tcpServer); new MasterLoginManager();//创建登录管理类 } else { TCPManager.Instance.InitNetWork(new TcpClient((p) => StudentStateManager.Instance.NetworkConnections = p)); SceneSystem.Instance.SetScene(new StudentLoginScene(LoadSceneType.unLogin)); } } private void Update() { TCPManager.Instance.ExtractingMsg(); } //程序退出时执行 private void OnApplicationQuit() { Debug.Log("Quit"); TCPManager.Instance?.Close(); DBManager.Instance?.CloseSqlConnectionDB(); } }