暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SelfControllerEditor.cs 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace UnityEditor.UI
  4. {
  5. /// <summary>
  6. /// Base class for custom editors that are for components that implement the SelfControllerEditor interface.
  7. /// </summary>
  8. public class SelfControllerEditor : Editor
  9. {
  10. 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.";
  11. public override void OnInspectorGUI()
  12. {
  13. bool anyHaveLayoutParent = false;
  14. for (int i = 0; i < targets.Length; i++)
  15. {
  16. Component comp = (targets[i] as Component);
  17. ILayoutIgnorer ignorer = comp.GetComponent(typeof(ILayoutIgnorer)) as ILayoutIgnorer;
  18. if (ignorer != null && ignorer.ignoreLayout)
  19. continue;
  20. RectTransform parent = comp.transform.parent as RectTransform;
  21. if (parent != null)
  22. {
  23. Behaviour layoutGroup = parent.GetComponent(typeof(ILayoutGroup)) as Behaviour;
  24. if (layoutGroup != null && layoutGroup.enabled)
  25. {
  26. anyHaveLayoutParent = true;
  27. break;
  28. }
  29. }
  30. }
  31. if (anyHaveLayoutParent)
  32. EditorGUILayout.HelpBox(string.Format(s_Warning, ObjectNames.NicifyVariableName(target.GetType().Name)), MessageType.Warning);
  33. }
  34. }
  35. }