private void Awake() { /// 创建一个tcp传输实例 transfer = new UnityDebugViewerTransfer(); /// 创建一个tcp server socket并侦听50000端口 transfer.CreateServerSocket(50000); /// 开始收集log信息 Application.logMessageReceivedThreaded += CaptureLogThread; DontDestroyOnLoad(this.gameObject); }
public static void CreateServerSocket(int port) { if (transferInstance == null) { transferInstance = new UnityDebugViewerTransfer(); transferInstance.disconnectToServerEvent += disconnectToServerEvent; transferInstance.disconnectToClientrEvent += disconnectToClientrEvent; transferInstance.receiveDaraFromServerEvent += receiveDaraFromServerEvent; transferInstance.receiveDaraFromClientEvent += receiveDaraFromClientEvent; } transferInstance.CreateServerSocket(port); }
public static void ConnectToServer(string ip, int port) { if (transferInstance == null) { transferInstance = new UnityDebugViewerTransfer(); transferInstance.disconnectToServerEvent += disconnectToServerEvent; transferInstance.disconnectToClientrEvent += disconnectToClientrEvent; transferInstance.receiveDaraFromServerEvent += receiveDaraFromServerEvent; transferInstance.receiveDaraFromClientEvent += receiveDaraFromClientEvent; } transferInstance.ConnectToServer(ip, port); }