架构大更
This commit is contained in:
@@ -1,33 +1,40 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
[CustomEditor(typeof(WindowManager))]
|
||||
public class WindowManagerEditor : Editor
|
||||
{
|
||||
private GUISkin customSkin;
|
||||
private WindowManager wmTarget;
|
||||
private UIManagerWindowManager tempUIM;
|
||||
private int currentTab;
|
||||
private GUISkin customSkin;
|
||||
private UIManagerWindowManager tempUIM;
|
||||
private WindowManager wmTarget;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
wmTarget = (WindowManager)target;
|
||||
|
||||
try { tempUIM = wmTarget.GetComponent<UIManagerWindowManager>(); }
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
tempUIM = wmTarget.GetComponent<UIManagerWindowManager>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (EditorGUIUtility.isProSkin == true) { customSkin = MUIPEditorHandler.GetDarkEditor(customSkin); }
|
||||
else { customSkin = MUIPEditorHandler.GetLightEditor(customSkin); }
|
||||
if (EditorGUIUtility.isProSkin)
|
||||
customSkin = MUIPEditorHandler.GetDarkEditor(customSkin);
|
||||
else
|
||||
customSkin = MUIPEditorHandler.GetLightEditor(customSkin);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
MUIPEditorHandler.DrawComponentHeader(customSkin, "WM Top Header");
|
||||
|
||||
GUIContent[] toolbarTabs = new GUIContent[2];
|
||||
var toolbarTabs = new GUIContent[2];
|
||||
toolbarTabs[0] = new GUIContent("Content");
|
||||
toolbarTabs[1] = new GUIContent("Settings");
|
||||
|
||||
@@ -53,38 +60,44 @@ namespace Michsky.MUIP
|
||||
|
||||
if (wmTarget.windows.Count != 0)
|
||||
{
|
||||
if (Application.isPlaying == true) { GUI.enabled = false; }
|
||||
if (Application.isPlaying) GUI.enabled = false;
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Selected Window:"), customSkin.FindStyle("Text"), GUILayout.Width(120));
|
||||
currentWindowIndex.intValue = EditorGUILayout.IntSlider(currentWindowIndex.intValue, 0, wmTarget.windows.Count - 1);
|
||||
EditorGUILayout.LabelField(new GUIContent("Selected Window:"), customSkin.FindStyle("Text"),
|
||||
GUILayout.Width(120));
|
||||
currentWindowIndex.intValue = EditorGUILayout.IntSlider(currentWindowIndex.intValue, 0,
|
||||
wmTarget.windows.Count - 1);
|
||||
|
||||
GUILayout.Space(2);
|
||||
EditorGUILayout.LabelField(new GUIContent(wmTarget.windows[currentWindowIndex.intValue].windowName), customSkin.FindStyle("Text"));
|
||||
EditorGUILayout.LabelField(
|
||||
new GUIContent(wmTarget.windows[currentWindowIndex.intValue].windowName),
|
||||
customSkin.FindStyle("Text"));
|
||||
|
||||
if (Application.isPlaying == false && wmTarget.windows[currentWindowIndex.intValue].windowObject != null)
|
||||
{
|
||||
for (int i = 0; i < wmTarget.windows.Count; i++)
|
||||
{
|
||||
if (i == currentWindowIndex.intValue)
|
||||
if (!Application.isPlaying &&
|
||||
wmTarget.windows[currentWindowIndex.intValue].windowObject != null)
|
||||
for (var i = 0; i < wmTarget.windows.Count; i++)
|
||||
if (i == currentWindowIndex.intValue)
|
||||
{
|
||||
var tempCG = wmTarget.windows[currentWindowIndex.intValue].windowObject.GetComponent<CanvasGroup>();
|
||||
if (tempCG != null) { tempCG.alpha = 1; }
|
||||
var tempCG = wmTarget.windows[currentWindowIndex.intValue].windowObject
|
||||
.GetComponent<CanvasGroup>();
|
||||
if (tempCG != null) tempCG.alpha = 1;
|
||||
}
|
||||
|
||||
else if (wmTarget.windows[i].windowObject != null)
|
||||
{
|
||||
var tempCG = wmTarget.windows[i].windowObject.GetComponent<CanvasGroup>();
|
||||
if (tempCG != null) { tempCG.alpha = 0; }
|
||||
if (tempCG != null) tempCG.alpha = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = true;
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
else { EditorGUILayout.HelpBox("Window List is empty. Create a new item to see more options.", MessageType.Info); }
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Window List is empty. Create a new item to see more options.",
|
||||
MessageType.Info);
|
||||
}
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
EditorGUI.indentLevel = 1;
|
||||
@@ -102,8 +115,10 @@ namespace Michsky.MUIP
|
||||
|
||||
case 1:
|
||||
MUIPEditorHandler.DrawHeader(customSkin, "Options Header", 6);
|
||||
cullWindows.boolValue = MUIPEditorHandler.DrawToggle(cullWindows.boolValue, customSkin, "Cull Transparent Windows");
|
||||
initializeButtons.boolValue = MUIPEditorHandler.DrawToggle(initializeButtons.boolValue, customSkin, "Initialize Buttons");
|
||||
cullWindows.boolValue =
|
||||
MUIPEditorHandler.DrawToggle(cullWindows.boolValue, customSkin, "Cull Transparent Windows");
|
||||
initializeButtons.boolValue = MUIPEditorHandler.DrawToggle(initializeButtons.boolValue, customSkin,
|
||||
"Initialize Buttons");
|
||||
|
||||
MUIPEditorHandler.DrawHeader(customSkin, "UIM Header", 10);
|
||||
|
||||
@@ -115,22 +130,29 @@ namespace Michsky.MUIP
|
||||
EditorApplication.ExecuteMenuItem("Tools/Modern UI Pack/Show UI Manager");
|
||||
|
||||
if (GUILayout.Button("Disable UI Manager Connection", customSkin.button))
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("Modern UI Pack", "Are you sure you want to disable UI Manager connection with the object? " +
|
||||
"This operation cannot be undone.", "Yes", "Cancel"))
|
||||
{
|
||||
try { DestroyImmediate(tempUIM); }
|
||||
catch { Debug.LogError("<b>[Window Manager]</b> Failed to delete UI Manager connection.", this); }
|
||||
}
|
||||
}
|
||||
if (EditorUtility.DisplayDialog("Modern UI Pack",
|
||||
"Are you sure you want to disable UI Manager connection with the object? " +
|
||||
"This operation cannot be undone.", "Yes", "Cancel"))
|
||||
try
|
||||
{
|
||||
DestroyImmediate(tempUIM);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.LogError("<b>[Window Manager]</b> Failed to delete UI Manager connection.",
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
else if (tempUIM == null) { MUIPEditorHandler.DrawUIManagerDisconnectedHeader(); }
|
||||
else if (tempUIM == null)
|
||||
{
|
||||
MUIPEditorHandler.DrawUIManagerDisconnectedHeader();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (Application.isPlaying == false) { this.Repaint(); }
|
||||
if (!Application.isPlaying) Repaint();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user