public override void OnInspectorGUI() { if (folderLoaded) { EditorTools.Message_static("Loading Complete", "Loaded " + modelCount.ToString() + " models from 'Assets/" + folderString + "."); folderLoaded = false; folderString = ""; filePathsToLoad = null; } DrawDefaultInspector(); if (tools.Button("Load Folder")) { if (tools.Message("Load Baked Animation In Folder", "Select one of the models in the folder you wish to load.", "OK", "Cancel")) { EditorGUIUtility.ShowObjectPicker <GameObject>(null, false, "", objectPickerID); } GUIUtility.ExitGUI(); } Event currentEvent = Event.current; if (currentEvent.type == EventType.ExecuteCommand || currentEvent.type == EventType.ValidateCommand) { if (currentEvent.commandName == "ObjectSelectorClosed") { if (EditorGUIUtility.GetObjectPickerControlID() == objectPickerID) { Object pickedObject = EditorGUIUtility.GetObjectPickerObject(); if (pickedObject != null) { folderString = AssetDatabase.GetAssetPath(pickedObject); folderString = folderString.Replace(Path.GetFileName(folderString), ""); folderString = folderString.Replace("Assets/", ""); filePathsToLoad = Directory.GetFiles(Application.dataPath + "/" + folderString); bool replaceExisting = tools.Message("Load Folder", "Replace any existing models?", "Yes", "No"); tools.StartEdit(animator, "Mesh Animator Loaded models"); if (replaceExisting) { animator.models.Clear(); } modelCount = animator.LoadFromFolder(filePathsToLoad, folderString); tools.EndEdit(animator); folderLoaded = true; GUIUtility.ExitGUI(); } } } } if (animator.paused) { if (tools.Button("Play")) { animator.Play(); } } else { if (tools.Button("Pause")) { animator.Pause(); } } }
void OnGUI() { if (readyToClose) { /* * tools.Label("Mesh Animator Creator has finished!"); * if(tools.Button("Close")) * { * this.Close(); * } */ this.Close(); GUIUtility.ExitGUI(); return; } else { tools.Label("Mesh Animator Creator is Active..."); } if (showPicker) { EditorGUIUtility.ShowObjectPicker <GameObject>(null, false, "", GetInstanceID()); showPicker = false; GUIUtility.ExitGUI(); return; } if (folderLoaded) { EditorTools.Message_static("Loading Complete", "Loaded " + modelCount.ToString() + " models from 'Assets/" + folderString + "."); folderLoaded = false; folderString = ""; filePathsToLoad = null; foreach (GameObject obj in objectList) { CreateMeshAnimator(obj, currentAnimator); } readyToClose = true; GUIUtility.ExitGUI(); //this.Close(); //Destroy(this); return; } Event currentEvent = Event.current; if (currentEvent.type == EventType.ExecuteCommand || currentEvent.type == EventType.ValidateCommand) { if (currentEvent.commandName == "ObjectSelectorClosed") { if (EditorGUIUtility.GetObjectPickerControlID() == GetInstanceID()) { Object pickedObject = EditorGUIUtility.GetObjectPickerObject(); if (pickedObject != null) { folderString = AssetDatabase.GetAssetPath(pickedObject); folderString = folderString.Replace(Path.GetFileName(folderString), ""); folderString = folderString.Replace("Assets/", ""); filePathsToLoad = Directory.GetFiles(Application.dataPath + "/" + folderString); bool replaceExisting = tools.Message("Load Folder", "Replace any existing models?", "Yes", "No"); if (replaceExisting) { currentAnimator.models.Clear(); } modelCount = currentAnimator.LoadFromFolder(filePathsToLoad, folderString); folderLoaded = true; GUIUtility.ExitGUI(); return; } } } } }