public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { FGUI_Inspector.DrawUILine(Attribute.color); }
/// <summary> /// Searching for animator in given root object and it's parents /// If you want to search new aniamtor you have to call ResetFinders() /// </summary> /// <returns> Returns true if animator is found, enabled and have controller </returns> public static bool CheckForAnimator(GameObject root, bool needAnimatorBox = true, bool drawInactiveWarning = true, int clicksTohide = 1) { bool working = false; if (checkForAnim) { FoundAnimator = SearchForParentWithAnimator(root); } // Drawing animator specific dialogs if (FoundAnimator) { Animation legacy = FoundAnimator as Animation; Animator mec = FoundAnimator as Animator; if (legacy) { if (legacy.enabled) { working = true; } } if (mec) // Mecanim found but no controller assigned { if (mec.enabled) { working = true; } if (mec.runtimeAnimatorController == null) { EditorGUILayout.HelpBox(" No 'Animator Controller' inside Animator (" + FoundAnimator.transform.name + ")", MessageType.Warning); drawInactiveWarning = false; working = false; } } // Drawing dialogs for warnings if (needAnimatorBox) { if (drawInactiveWarning) { if (!working) { GUILayout.Space(-4); FGUI_Inspector.DrawWarning(" ANIMATOR IS DISABLED! "); GUILayout.Space(2); } } } } else { if (needAnimatorBox) { if (clicks < clicksTohide) { GUILayout.Space(-4); if (FGUI_Inspector.DrawWarning(" ANIMATOR NOT FOUND! ")) { clicks++; } GUILayout.Space(2); } } } checkForAnim = false; return(working); }
public static bool CheckForAnimator(GameObject root, bool needAnimatorBox = true, bool drawInactiveWarning = true) { Animation animation = null; Animator animator = root.GetComponentInChildren <Animator>(); if (!animator) { if (root.transform.parent) { if (root.transform.parent.parent) { animator = root.transform.parent.parent.GetComponentInChildren <Animator>(); } else { animator = root.transform.parent.GetComponent <Animator>(); } } } if (!animator) { animation = root.GetComponentInChildren <Animation>(); if (!animation) { if (root.transform.parent) { if (root.transform.parent.parent) { animation = root.transform.parent.parent.GetComponentInChildren <Animation>(); } else { animation = root.transform.parent.GetComponent <Animation>(); } } } } if (animator) { if (animator.runtimeAnimatorController == null) { EditorGUILayout.HelpBox("No 'Animator Controller' inside Animator", MessageType.Warning); animator = null; } } if (needAnimatorBox) { if (animator == null && animation == null) { GUILayout.Space(-4); FGUI_Inspector.DrawWarning(" ANIMATOR NOT FOUND! "); GUILayout.Space(2); } else if (drawInactiveWarning) { bool drawInact = false; if (animator != null) { if (animator.enabled == false) { drawInact = true; } } if (animation != null) { if (animation.enabled == false) { drawInact = true; } } if (drawInact) { GUILayout.Space(-4); FGUI_Inspector.DrawWarning(" ANIMATOR IS DISABLED! "); GUILayout.Space(2); } } } if (animator != null || animation != null) { if (animator) { if (!animator.enabled) { return(false); } } if (animation) { if (!animation.enabled) { return(false); } } return(true); } else { return(false); } }