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; }
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; }
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(); }