From d07e14add74e017b52ab2371efeea1aa4ea10ced Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 8 May 2021 23:15:13 +0800 Subject: +init --- .../Editor/EventSystem/EventSystemEditor.cs | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs (limited to 'Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs') diff --git a/Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs b/Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs new file mode 100644 index 0000000..729b584 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs @@ -0,0 +1,66 @@ +using UnityEngine; +using UnityEngine.EventSystems; + +namespace UnityEditor.EventSystems +{ + [CustomEditor(typeof(EventSystem), true)] + public class EventSystemEditor : Editor + { + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + var eventSystem = target as EventSystem; + if (eventSystem == null) + return; + + if (eventSystem.GetComponent() != null) + return; + + // no input modules :( + if (GUILayout.Button("Add Default Input Modules")) + { + Undo.AddComponent(eventSystem.gameObject); + } + } + + public override bool HasPreviewGUI() + { + return Application.isPlaying; + } + + private GUIStyle m_PreviewLabelStyle; + + protected GUIStyle previewLabelStyle + { + get + { + if (m_PreviewLabelStyle == null) + { + m_PreviewLabelStyle = new GUIStyle("PreOverlayLabel") + { + richText = true, + alignment = TextAnchor.UpperLeft, + fontStyle = FontStyle.Normal + }; + } + + return m_PreviewLabelStyle; + } + } + + public override bool RequiresConstantRepaint() + { + return Application.isPlaying; + } + + public override void OnPreviewGUI(Rect rect, GUIStyle background) + { + var system = target as EventSystem; + if (system == null) + return; + + GUI.Label(rect, system.ToString(), previewLabelStyle); + } + } +} -- cgit v1.1-26-g67d0