public void GetFile() { if (textFile && textFile.FileExists()) { textFile.GetData(); for (int i = 0; i < textFile.value.Length; i++) { if (textFile.value[i].Length > 0) { string[] data = ECCommons.Separate(textFile.separator, textFile.value[i]); switch (i) { case 0: portName = data[1]; break; case 1: timeout = int.Parse(data[1]); break; case 2: buffer = int.Parse(data[1]); break; case 3: readLength = int.Parse(data[1]); break; } } } } storeName = portName; tmpBuffer = buffer; state = ConnectionState.DISCONNECTED; }
void UpdateBlackList() { if (ECFile.FileExists("../Resources/BlackList.txt")) { string[] data = ECFile.ReadLines("../Resources/BlackList.txt"); projectorManager.RenewBlackList(data); } }
public void ShutDown() { //projectorManager.ShutdownSystem(); if (ECFile.FileExists("../Resources/ShutDown.bat")) { System.Diagnostics.Process.Start("cmd", "/C start /min " + ECFile.Path("../Resources/ShutDown.bat")); } Quit(); }
public void Save(string path) { ECFile store = new ECFile(path); if (!store.DirectoryExists()) { store.CreateDirectory(); } path = store.directory + "/" + store.file + "_"; totalPaint++; while (ECFile.FileExists(path + ECCommons.FixLength(totalPaint, 0, 3) + "." + store.extension)) { totalPaint++; } paint.SaveTexture(path + ECCommons.FixLength(totalPaint, 0, 3) + "." + store.extension); }
public void GetFile() { if (textFile && textFile.FileExists()) { textFile.GetData(); for (int i = 0; i < textFile.value.Length; i++) { string[] data = ECCommons.Separate(textFile.separator, textFile.value[i]); if (data.Length > 1) { switch (i) { case 0: connectName = data[1]; break; case 1: appName = data[1]; break; case 2: useUnityServer = data[1].Contains("T"); break; case 3: serverIP = data[1]; break; case 4: serverPort = int.Parse(data[1]); break; case 5: facilitatorIP = data[1]; break; case 6: facilitatorPort = int.Parse(data[1]); break; } } } } if (!useUnityServer) { MasterServer.ipAddress = serverIP; MasterServer.port = serverPort; Network.natFacilitatorIP = facilitatorIP; Network.natFacilitatorPort = facilitatorPort; } state = ConnectionState.DISCONNECTED; }
// Update is called once per frame void Update() { if (arduinos.autoConnect != auto[0].isOn) { arduinos.autoConnect = auto[0].isOn; } if (networks.autoConnect != auto[1].isOn) { networks.autoConnect = auto[1].isOn; } //Arduino if (!status[0].text.Equals(arduinos.state.ToString())) { status[0].text = arduinos.state.ToString(); } switch (connectBtn[0].gameObject.activeSelf) { case true: if (auto[0].isOn || arduinos.state == ConnectionState.CONNECTING || !arduinos.ArduinoExisted()) { connectBtn[0].gameObject.SetActive(false); } break; default: if (!auto[0].isOn && arduinos.state != ConnectionState.CONNECTING && arduinos.ArduinoExisted()) { connectBtn[0].gameObject.SetActive(true); } break; } switch (arduinos.state) { case ConnectionState.CONNECTED: btnText[0].text = "Disonnect"; break; default: btnText[0].text = "Connect"; break; } //Network if (!status[1].text.Equals(networks.state.ToString())) { status[1].text = networks.state.ToString(); } switch (connectBtn[1].gameObject.activeSelf) { case true: if (auto[0].isOn || networks.state == ConnectionState.CONNECTING) { connectBtn[1].gameObject.SetActive(false); } break; default: if (!auto[0].isOn && networks.state != ConnectionState.CONNECTING) { connectBtn[1].gameObject.SetActive(true); } break; } if (!networks.HostFound()) { btnText[1].text = "Search"; } else { switch (networks.state) { case ConnectionState.CONNECTED: btnText[0].text = "Disonnect"; break; default: btnText[0].text = "Connect"; break; } } //Data R/W if (quitByExisting == ECFile.FileExists(quitText)) { ECFile.DeleteFile(quitText); arduinos.autoConnect = false; arduinos.Disconnect(); networks.autoConnect = false; networks.Disconnect(); Application.Quit(); } else { if (networks.state == ConnectionState.CONNECTED) { if (!networks.transferedData.Equals(arduinos.receivedData)) { networks.DataTransfer(arduinos.receivedData); } } if (arduinos.state == ConnectionState.CONNECTED) { if (!arduinos.transferedData.Equals(networks.receivedData)) { arduinos.DataTransfer(networks.receivedData); } } } data = "Received: " + arduinos.receivedData + "\n" + "Transferred: " + networks.receivedData; dataText.text = data; }
public override void OnInspectorGUI() { //DrawDefaultInspector(); script = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript; if (script != MonoScript.FromMonoBehaviour(editor)) { script = MonoScript.FromMonoBehaviour(editor); } GUILayout.BeginHorizontal(); if (GUILayout.Button("Select Directory")) { string path = EditorUtility.OpenFolderPanel("Please select a folder", editor.directory, ""); if (path.Length > 0) { editor.directory = path; string[] files = ECFile.FileCounts(editor.directory); foreach (string f in files) { Debug.Log(ECFile.FileName(f) + "." + ECFile.Extension(f)); } Debug.Log(files.Length + " file(s) found."); } EditorUtility.SetDirty(editor); } if (editor.FileExists()) { if (GUILayout.Button("Explorer")) { string path = System.IO.Path.GetFullPath(editor.Path().Replace(@"/", @"\")); System.Diagnostics.Process.Start("explorer.exe", "/select," + path); } } GUILayout.EndHorizontal(); EditorGUILayout.LabelField("Path", EditorStyles.boldLabel); editor.directory = EditorGUILayout.TextField("Current Directory: ", editor.directory); editor.file = EditorGUILayout.TextField("Current File Name: ", editor.file); editor.extension = EditorGUILayout.TextField("Current Extension: ", editor.extension); GUILayout.BeginHorizontal(); if (GUILayout.Button("Load File")) { string path = EditorUtility.OpenFilePanel("Please pick a file", editor.directory, editor.extension); if (path.Length > 0) { editor.directory = ECFile.DirectoryName(path); editor.file = ECFile.FileName(path); editor.extension = ECFile.Extension(path); editor.GetData(); foreach (string d in editor.value) { Debug.Log(d); } } EditorUtility.SetDirty(editor); } if (editor.FileExists()) { if (GUILayout.Button("Save File")) { editor.SetData(); } } GUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Data", EditorStyles.boldLabel); editor.separator = EditorGUILayout.TextField("Separator: ", editor.separator); editor.dataLength = EditorGUILayout.IntField("Number of data: ", editor.dataLength, EditorStyles.boldLabel); if (editor.data.Length != editor.dataLength) { editor.ResizeData(); } for (int i = 0; i < editor.data.Length; i++) { editor.data[i] = EditorGUILayout.TextField(" - Data Name " + (i + 1) + ": ", editor.data[i]); } if (editor.FileExists()) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Clear File")) { editor.ClearFile(); } if (GUILayout.Button("Delete File")) { editor.DeleteFile(); } GUILayout.EndHorizontal(); } else { if (GUILayout.Button("Create File")) { if (!editor.DirectoryExists()) { editor.CreateDirectory(); } editor.CreateFile(); } } //GUILayout.BeginHorizontal(); //data = EditorGUILayout.TextField("Data", data); //EditorGUILayout.LabelField("", value); //GUILayout.EndHorizontal(); }
// Update is called once per frame void Update() { if (arduinos.autoConnect != auto[0].isOn) { arduinos.autoConnect = auto[0].isOn; } if (fReaders.autoGenFolder != auto[1].isOn) { fReaders.autoGenFolder = auto[1].isOn; } //Arduino if (!status[0].text.Equals(arduinos.state.ToString())) { status[0].text = arduinos.state.ToString(); } switch (connectBtn[0].gameObject.activeSelf) { case true: if (auto[0].isOn || arduinos.state == ConnectionState.CONNECTING || !arduinos.ArduinoExisted()) { connectBtn[0].gameObject.SetActive(false); } break; default: if (!auto[0].isOn && arduinos.state != ConnectionState.CONNECTING && arduinos.ArduinoExisted()) { connectBtn[0].gameObject.SetActive(true); } break; } switch (arduinos.state) { case ConnectionState.CONNECTED: btnText[0].text = "Disonnect"; break; default: btnText[0].text = "Connect"; break; } //Folder switch (connectBtn[1].gameObject.activeSelf) { case true: if (auto[1].isOn || fReaders.ReceiverFound() && fReaders.TransmitterFound()) { connectBtn[1].gameObject.SetActive(false); status[1].text = "EXIST"; } break; default: if (!auto[1].isOn && (!fReaders.ReceiverFound() || !fReaders.TransmitterFound())) { connectBtn[1].gameObject.SetActive(true); status[1].text = "LOST"; } break; } //Data R/W if (quitByExisting == ECFile.FileExists(quitText)) { ECFile.DeleteFile(quitText); arduinos.autoConnect = false; arduinos.Disconnect(); Application.Quit(); } else { if (!fReaders.transferedData.Substring(fReaders.orderLength).Equals(arduinos.receivedData)) { fReaders.DataTransfer(arduinos.receivedData); } if (arduinos.state == ConnectionState.CONNECTED) { if (!arduinos.transferedData.Equals(fReaders.receivedData)) { arduinos.DataTransfer(fReaders.receivedData); } } } data = "Received: " + arduinos.receivedData + "\n" + "Transferred: " + fReaders.receivedData; dataText.text = data; }