public override void OnInspectorGUI() { PiXYZImportSettings importSettings = target as PiXYZImportSettings; importSettings.windowId = GetInstanceID(); importSettings.isInspector = true; EditorGUILayout.BeginVertical(); EditorGUILayout.Space(); GUI.enabled = false; if (System.IO.File.Exists(importSettings.settings.originalFilename)) { EditorGUILayout.TextField(new GUIContent("Original File"), importSettings.settings.originalFilename); } else { GUIStyle redFont = new GUIStyle(EditorStyles.textField); redFont.normal.textColor = Color.red; EditorGUILayout.TextField("Original File", "Original File Missing", redFont); } if (importSettings.settings.originalFilename == "") { return; } GUI.enabled = true; EditorGUILayout.Space(); utils.GUISettings(serializedObject, gameObject: importSettings.gameObject); EditorGUILayout.Space(); //EditorGUILayout.BeginHorizontal(); //GUILayout.FlexibleSpace(); //string tooltips = "Click to apply new settings."; //if (GUILayout.Button(new GUIContent("Apply", tooltips), GUILayout.Width(150.0f))) // if(EditorUtility.DisplayDialog("Warning!", "Caution! This action will completely re-import the model, all modifications will be lost, including material assignation.\n\nAre you sure you want to apply changes?", "Yes", "No")) // OnApplyClicked(); //GUILayout.FlexibleSpace(); //EditorGUILayout.EndHorizontal(); //EditorGUILayout.Space(); EditorGUILayout.EndVertical(); EditorUtility.SetDirty(importSettings); }
void OnGUI() { serializedObject.Update(); EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true), GUILayout.MaxWidth(Screen.width)); { GUILayout.Space(5); EditorGUI.indentLevel++; EditorGUILayout.BeginVertical(); { EditorGUI.BeginDisabledGroup(coroutineScheduler.HasCoroutines()); { GUILayout.Space(20); PiXYZUtils.beginGroupBox("Importing File"); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.TextField("File Name", Path.GetFileName(selectedFile)); GUIStyle btnStyle = new GUIStyle(GUI.skin.button); btnStyle.margin.top = 0; if (GUILayout.Button(new GUIContent("... ", "Open browser and choose the import to import"), btnStyle, GUILayout.Width(25))) { OnFileSelectionClicked(); } GUILayout.Space(40); } EditorGUILayout.EndHorizontal(); } PiXYZUtils.endGroupBox(); GUI.enabled = isFileNameValid && !coroutineScheduler.HasCoroutines(); if (isFileNameValid) { string ext = Path.GetExtension(selectedFile); utils.GUISettings(serializedObject, ext); if (maxSize.y == 110.0f || (maxSize.y > 300.0f && PiXYZUtils.isPiXYZExt(ext)) || (maxSize.y < 300.0f && !PiXYZUtils.isPiXYZExt(ext))) { minSize = new Vector2(430.0f, !PiXYZUtils.isPiXYZExt(ext) ? 660.0f : 240.0f); maxSize = new Vector2(430.0f, !PiXYZUtils.isPiXYZExt(ext) ? 700.0f : 260.0f); this.CenterOnMainWin(); } } else if (!isFileNameValid && maxSize.y > 110.0f) { minSize = new Vector2(430.0f, 100.0f); maxSize = new Vector2(430.0f, 110.0f); this.CenterOnMainWin(); } GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginHorizontal(GUILayout.Width(Screen.width / 2)); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Import", GUILayout.Width(80))) { OnImportClicked(); } GUI.enabled = true; GUILayout.Space(15); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Space(15); if (GUILayout.Button("Cancel", GUILayout.Width(80))) { OnCancelClicked(); } GUILayout.FlexibleSpace(); if (isFileNameValid && !PiXYZUtils.isPiXYZExt(selectedFile)) { GUIStyle bs = new GUIStyle(GUI.skin.button); bs.normal.background = saveIconNormal; // Resources.Load("icon/save_32_Roll") as Texture2D; bs.hover.background = saveIconHover; // Resources.Load("icon/save_32_Roll1") as Texture2D; bs.active.background = saveIconActive; // Resources.Load("icon/Save_32_Roll2") as Texture2D; bs.border = new RectOffset(0, 0, 0, 0); bs.margin = new RectOffset(0, 0, 0, 0); bs.overflow = new RectOffset(0, 0, 0, 0); if (GUILayout.Button("", bs, GUILayout.Width(24), GUILayout.Height(24))) { PiXYZUtils.saveEditorPref(serializedObject); } bs.normal.background = resetIconNormal; // Resources.Load("icon/Reset_32_Roll") as Texture2D; bs.hover.background = resetIconHover; // Resources.Load("icon/Reset_32_Roll1") as Texture2D; bs.active.background = resetIconActive; // Resources.Load("icon/Reset_32_Roll2") as Texture2D; if (GUILayout.Button("", bs, GUILayout.Width(24), GUILayout.Height(24))) { importSettings = ScriptableObject.CreateInstance <ImportSettings>(); serializedObject = new SerializedObject(importSettings); importSettings.windowId = GetInstanceID(); PiXYZLods.reset = true; } bs.normal.background = resetFactoryIconNormal; // Resources.Load("icon/ResetUsine_32_Roll") as Texture2D; bs.hover.background = resetFactoryIconHover; // Resources.Load("icon/ResetUsine_32_Roll1") as Texture2D; bs.active.background = resetFactoryIconActive; // Resources.Load("icon/ResetUsine_32_Roll2") as Texture2D; if (GUILayout.Button("", bs, GUILayout.Width(24), GUILayout.Height(24))) { importSettings.settings.factoryReset(); serializedObject = new SerializedObject(importSettings); importSettings.windowId = GetInstanceID(); PiXYZLods.reset = true; } GUILayout.Space(10); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndHorizontal(); } EditorGUI.EndDisabledGroup(); GUILayout.Space(10); } EditorGUILayout.EndVertical(); GUILayout.Space(5); EditorGUI.indentLevel--; } EditorGUILayout.EndHorizontal(); }