From d07e14add74e017b52ab2371efeea1aa4ea10ced Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 8 May 2021 23:15:13 +0800 Subject: +init --- .../uGUI-2017.1/Editor/UI/SelfControllerEditor.cs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs (limited to 'Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs') diff --git a/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs b/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs new file mode 100644 index 0000000..4510d44 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + public class SelfControllerEditor : Editor + { + static string s_Warning = "Parent has a type of layout group component. A child of a layout group should not have a {0} component, since it should be driven by the layout group."; + + public override void OnInspectorGUI() + { + bool anyHaveLayoutParent = false; + for (int i = 0; i < targets.Length; i++) + { + Component comp = (targets[i] as Component); + ILayoutIgnorer ignorer = comp.GetComponent(typeof(ILayoutIgnorer)) as ILayoutIgnorer; + if (ignorer != null && ignorer.ignoreLayout) + continue; + + RectTransform parent = comp.transform.parent as RectTransform; + if (parent != null) + { + Behaviour layoutGroup = parent.GetComponent(typeof(ILayoutGroup)) as Behaviour; + if (layoutGroup != null && layoutGroup.enabled) + { + anyHaveLayoutParent = true; + break; + } + } + } + if (anyHaveLayoutParent) + EditorGUILayout.HelpBox(string.Format(s_Warning, ObjectNames.NicifyVariableName(target.GetType().Name)), MessageType.Warning); + } + } +} -- cgit v1.1-26-g67d0