override public void OnInspectorGUI() { DrawDefaultInspector(); GUI.enabled = true; if (meshPath == null) { mesh = (UnityEngine.Mesh)target; assetPath = AssetDatabase.GetAssetPath(target); assetGUID = AssetDatabase.AssetPathToGUID(assetPath); GameObject asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject; meshPath = KrablMesh.UnityEditorUtils.MeshPathInAsset(mesh, asset); } if (prog == null && searchedForProgram == false) { _initializeProgram(); searchedForProgram = true; } // Mesh information on top. // Mesh path string path = ""; if (assetPath != null && assetPath != "") { path += assetPath.Replace("Assets/", "") + " - "; } GUILayout.BeginHorizontal(); GUILayout.Label("Mesh Path: ", GUILayout.Width(80.0f)); GUILayout.Label(path + meshPath); GUILayout.EndHorizontal(); // Mesh description string desc; if (prog != null) { desc = prog.inMeshDescription; if (desc == null || desc == "") { desc = "n/a"; } } else { desc = KMProcessorProgram.MeshDescription(mesh); } GUILayout.BeginHorizontal(); GUILayout.Label("Description: ", GUILayout.Width(80.0f)); GUILayout.Label(desc); GUILayout.EndHorizontal(); GUI.enabled = true; if (prog != null && progGUI != null) { // The program object draws all the processors etc. progGUI.DrawImporterGUI(this); } // prog and progGUI might have disappeared from delete, so check again if (prog != null && progGUI != null) { // Draw the part below the processors with Apply and Revert if (progGUI.modifiedDuringLastUpdate) { hasChanges = true; } GUI.enabled = hasChanges; EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Revert", GUILayout.ExpandWidth(false))) { _revertProgramChanges(); return; } if (GUILayout.Button("Apply", GUILayout.ExpandWidth(false))) { GUI.FocusControl(""); // make sure text editor field get committed _applyProgramChanges(); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; } else { // Draw the Add mesh import program section. EditorGUILayout.Separator(); bool canUseProgram = (assetPath != null && assetPath != ""); #if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 if (mesh.blendShapeCount > 0) { canUseProgram = false; } #endif if (canUseProgram) { GUIStyle largeButtonStyle = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).GetStyle("LargeButton"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Add Mesh Import Program", largeButtonStyle)) { AddProgram(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { bool specialError = false; #if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 if (mesh.blendShapeCount > 0) { EditorGUILayout.HelpBox( "Meshes with blendshapes can not yet be processed by Krabl Mesh Processors.\n\n" + "Support will be added as soon as Unity exposes blendshape access in the API.", MessageType.Info); specialError = true; } #endif if (specialError == false) { EditorGUILayout.HelpBox( "Only meshes inside the project folder can have mesh import programs.\n\n" + "Built-In meshes and scene meshes are never imported by Unity.", MessageType.Info); } } } }