Exemplo n.º 1
0
        /************************************************************************************************************************/

        private void DoAnimatorGUI()
        {
            var hasAnimator = AnimatorProperty.objectReferenceValue != null;

            var color = GUI.color;

            if (!hasAnimator)
            {
                GUI.color = AnimancerEditorUtilities.WarningFieldColor;
            }

            EditorGUILayout.PropertyField(AnimatorProperty);

            if (!hasAnimator)
            {
                GUI.color = color;

                EditorGUILayout.HelpBox("An Animator is required in order to play animations." +
                                        " Click here to search for one nearby.",
                                        MessageType.Warning);

                if (AnimancerEditorUtilities.TryUseClickInLastRect())
                {
                    AnimancerEditorUtilities.ForEachTarget(AnimatorProperty, (property) =>
                    {
                        var target = (IAnimancerComponent)property.serializedObject.targetObject;

                        // Can't use AnimancerEditorUtilities.GetComponentInHierarchy
                        // because Animancer Lite leaves it outside the DLL.
                        var animator = target.gameObject.GetComponentInParent <Animator>();
                        if (animator == null)
                        {
                            animator = target.gameObject.GetComponentInChildren <Animator>();
                            if (animator == null)
                            {
                                Debug.Log("No Animator found on '" + target + "' or any of its parents or children." +
                                          " You must assign one manually.", target.gameObject);
                                return;
                            }
                        }

                        property.objectReferenceValue = animator;
                    });
                }
            }
        }