public void Constate2(int windowID) { if (GUI.Button(new Rect(10, 20, 150, 25), "OK")) { Debug.Log("TSB_Close"); s = false; //isGet = false; if (myThread != null) { SocketApp.isRun = false; if (myThread.IsAlive) { SocketApp.CloseAll(); //TCP_Handler.tcpClose(); //printall("no Loacal IP"); //SocketApp.acceptDone.Set(); } Thread.Sleep(100); myThread.Abort(); Debug.Log("Abort"); } //if (SocketApp.transMode == (int)SocketApp.Transfer_Mode.M_UDP) // SocketApp.CloseAll(); stop = false; sensornumber = ""; SocketApp.TCP_clientList.Clear(); } // Make the windows be draggable. GUI.DragWindow(new Rect(0, 0, 10000, 10000)); }
void OnGUI() { GUILayout.Label("pitch: " + TCP_Handler.pitch.ToString("0.00")); GUILayout.Label("roll: " + TCP_Handler.roll.ToString("0.00")); GUILayout.Label("yaw: " + TCP_Handler.yaw.ToString("0.00")); GUILayout.Label("Times: " + (int)time_f / 60 + "m" + (int)time_f % 60 + "s"); GUILayout.Label("connected number: " + SocketApp.TCP_clientList.Count); /*if (GUILayout.Button(TSB_Open, GUILayout.Height(50), GUILayout.Width(50)))//測試按鍵改成圖片用 * { * Debug.Log("TSB_Open"); * FileInfo.loadSettingFile(); * }*/ if (GUILayout.Button("TSB_Open"))//開啟 { Debug.Log("TSB_Open"); FileInfo.loadSettingFile(); } if (GUILayout.Button("TSB_Start"))//開始 { Debug.Log("TSB_Start"); myThread = new Thread(new ThreadStart(ServerProcess)); myThread.IsBackground = true; myThread.Start(); } GUI.color = Color.gray; if (GUILayout.Button("TSB_CLose"))//關閉 { s = false; //isGet = false; if (myThread != null) { SocketApp.isRun = false; if (myThread.IsAlive) { SocketApp.CloseAll(); TCP_Handler.tcpClose(); //printall("no Loacal IP"); SocketApp.acceptDone.Set(); } Thread.Sleep(100); myThread.Abort(); } if (SocketApp.transMode == (int)SocketApp.Transfer_Mode.M_UDP) { SocketApp.CloseAll(); } } GUI.color = Color.white; if (GUILayout.Button("TSB_Activate"))//啟動連線 { s = true; Debug.Log("TSB_Activate"); string msg = "#send$"; SocketApp.SendAll(msg); // do things Debug.Log("send_activate"); //StartCoroutine("Activate");//註解比較穩定 } GUI.color = Color.gray; if (GUILayout.Button("TSB_Stop"))//暫停 { s = false; Debug.Log("TSB_Stop"); string msg = "#stop$"; SocketApp.SendAll(msg); // do things Debug.Log("send_stop"); } if (GUILayout.Button("Restart")) //整個專案重新開始 { Debug.Log("Restart"); SocketApp.TCP_clientList.Clear(); Application.LoadLevel(Application.loadedLevel); } GUI.color = Color.white; GUILayout.Label(""); GUILayout.Label("connected sensors: "); if (TCP_Handler.SID_List.Count > 0) { foreach (int ID in TCP_Handler.SID_List) { //Debug.Log("sensor ID: " + ID); sensornumber += ID.ToString(); sensornumber += " "; } TCP_Handler.SID_List.Clear(); } GUILayout.Label(sensornumber); //目前連線的sensor if (TCP_Handler.sensor_num_ID.Count > 0 && s == true) //activate後傳值的數量 { foreach (int ID in TCP_Handler.sensor_num_ID) { Debug.Log("sensor ID: " + ID); } } }