private void FilesExplorer() { if (SerializableManager.current.Encrypt && SerializableManager.current.password != lastpassword) { this.CacheEncrytion.Clear();//old } //Back... EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("[FOLDER]", EditorStyles.boldLabel, GUILayout.Width(90)); EditorGUILayout.LabelField("[BACK]", GUILayout.MinWidth(20)); if (GUILayout.Button("Open", GUILayout.Width(110))) { GUIUtility.keyboardControl = 0; FilesPath = Path.GetFullPath(Path.Combine(FilesPath, @"..\")); } //to aling EditorGUILayout.LabelField("", EditorStyles.label, GUILayout.Width(110 * 2 + 4)); EditorGUILayout.EndHorizontal(); try { foreach (string DirectoryPath in Directory.GetDirectories(FilesPath)) { string FolderName = Path.GetFileName(DirectoryPath); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("[FOLDER]", EditorStyles.boldLabel, GUILayout.Width(90)); EditorGUILayout.LabelField(FolderName, GUILayout.MinWidth(20)); if (GUILayout.Button("Open", GUILayout.Width(110))) { GUIUtility.keyboardControl = 0; FilesPath = DirectoryPath; } //to aling EditorGUILayout.LabelField("", EditorStyles.label, GUILayout.Width(110 * 2 + 4)); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); foreach (string FilePath in Directory.GetFiles(FilesPath)) { string FileName = Path.GetFileName(FilePath); if (FileName == "Thumbs.db") { continue; } if (lastpassword == null || SerializableManager.current.password != lastpassword || !CacheEncrytion.ContainsKey(FileName)) { //create cache CacheEncrytion.Add(FileName, SerializableFiles.IsValid(FilePath)); } SerializableFiles.ValidsTypes ValidSave = SerializableFiles.ValidsTypes.Error; //SerializableFiles.IsValid(FilePath); CacheEncrytion.TryGetValue(FileName, out ValidSave); EditorGUILayout.BeginHorizontal(); bool valid = ValidSave != SerializableFiles.ValidsTypes.Error && ValidSave != SerializableFiles.ValidsTypes.ERROR_Enc; //File status EditorGUILayout.LabelField("[" + ValidSave.ToString().Replace("_", " ").ToUpper() + "]", valid ? ValidFile : NotValidFile, GUILayout.Width(90)); //File name EditorGUILayout.LabelField(FileName, GUILayout.MinWidth(200)); //File size EditorGUILayout.LabelField(FileSize(FilePath), TextButtonRight, GUILayout.Width(100)); //shows buttons? if (valid) { //View Button if (GUILayout.Button("View", GUILayout.Width(110))) { this.LoadGame(FileName); } //Load Button GUI.enabled = SerializableManager.current != null && SerializableManager.current.enabled && Application.isPlaying; if (GUILayout.Button("Load", GUILayout.Width(110))) { SerializableManager.LoadAll(FileName); } //Default Button GUI.enabled = SerializableManager.current != null; if (GUILayout.Button((SerializableManager.current.DefaultFileName == FileName ? "Remove Default" : "Set Default"), GUILayout.Width(110))) { if (SerializableManager.current.DefaultFileName == FileName) { FileName = SerializableManager.DefaultSaveName; } SerializableManager.current.DefaultFileName = FileName; } } else { if (ValidSave == SerializableFiles.ValidsTypes.Error) { EditorGUILayout.LabelField("This is not a valid saved", EditorStyles.label, GUILayout.Width(110 * 3 + 8)); } else if (ValidSave == SerializableFiles.ValidsTypes.ERROR_Enc) { EditorGUILayout.LabelField("The saved could not be decrypted, bad password?", EditorStyles.label, GUILayout.Width(110 * 3 + 8)); } else { EditorGUILayout.LabelField("INTERAL ERROR (A161)", EditorStyles.label, GUILayout.Width(110 * 3 + 8)); } } //Restart GUI Status GUI.enabled = true; EditorGUILayout.EndHorizontal(); } } catch (FileNotFoundException e) { GUI.color = Color.yellow; EditorGUILayout.HelpBox("The route " + e.FileName + " is not a folder!", MessageType.Error); } catch (Exception e) { GUI.color = Color.yellow; EditorGUILayout.HelpBox("Error: " + e.Message, MessageType.Error); } lastpassword = SerializableManager.current.password; }
private void FileView() { //not valid load if (GameLoad == null) { //i have to load? if (this.CurrentLoadPath == null || this.CurrentLoadPath.Length < 5) { //not have, is SerializableManager valid? if (SerializableManager.current != null) { SerializableFiles.ValidsTypes valid = SerializableFiles.IsValid(SerializableManager.current.DefaultFileName); if (valid == SerializableFiles.ValidsTypes.Valid || valid == SerializableFiles.ValidsTypes.Encrypted) { LoadGame(SerializableManager.current.DefaultFileName); return; } } this.FileViewActive = false;//change to File Explorer return; } else { SerializableFiles.ValidsTypes valid = SerializableFiles.IsValid(this.CurrentLoadPath); if (valid == SerializableFiles.ValidsTypes.Valid || valid == SerializableFiles.ValidsTypes.Encrypted) { LoadGame(this.CurrentLoadPath); } else { this.FileViewActive = false;//change to File Explorer return; } } } if (GameLoad is String) { GUI.color = Color.yellow; EditorGUILayout.HelpBox((String)GameLoad, MessageType.Error); return; } List <GameObjectValue> GameObject = (List <GameObjectValue>)GameLoad; for (int IDGameObject = 0; IDGameObject < GameObject.Count; IDGameObject++) { if (Foldout(-1, IDGameObject, GameObjectName(GameObject[IDGameObject].Searchkey, GameObject[IDGameObject].PrefabPath, GameObject[IDGameObject].Scripts), Tab1)) { for (int IDscript = 0; IDscript < GameObject[IDGameObject].Scripts.Count; IDscript++) { MonoBehaviourValues script = GameObject[IDGameObject].Scripts[IDscript]; if (Foldout(IDGameObject, IDscript, ScriptName(script.ClassTypeName) + "(Script) " + (script.Enable ? "Enable" : "Disabled"), Tab2)) { EditorGUILayout.LabelField("Field = (Value) as (Type)", Tab3); foreach (FieldValue FieldValue in script.ObjectsData) { EditorGUILayout.LabelField(AdapterField(FieldValue.field) + " = (" + FieldValue.value.ToString() + ") as (" + FieldValue.value.GetType().FullName + ")", Tab3); } } } } } }