Example #1
0
        /************************************************************************************************************************/

        /// <summary>Gathers the <see cref="_Animators"/> from the <see cref="Targets"/>.</summary>
        private bool GatherAnimators()
        {
            if (_Animators == null || _Animators.Length != Targets.Length)
            {
                _Animators = new Animator[Targets.Length];
            }

            _IsAnimatorOnSameObject = true;
            var hasChanged = false;

            for (int i = 0; i < _Animators.Length; i++)
            {
                var target   = Targets[i];
                var animator = target.Animator;

                if (animator != null && target.gameObject != animator.gameObject)
                {
                    _IsAnimatorOnSameObject = false;
                }

                if (_Animators[i] != animator)
                {
                    AnimancerEditorUtilities.SetIsInspectorExpanded(_Animators[i], true);
                    _Animators[i] = animator;
                    hasChanged    = true;
                }
            }

            return(hasChanged);
        }
Example #2
0
        /************************************************************************************************************************/

        /// <summary>
        /// Cleans up this editor.
        /// </summary>
        public void Destroy()
        {
            AnimancerEditorUtilities.SetIsInspectorExpanded(_Animators, true);

            if (_SerializedAnimator != null)
            {
                _SerializedAnimator.Dispose();
                _SerializedAnimator = null;
            }
        }
Example #3
0
        /************************************************************************************************************************/

        /// <summary>
        /// Creates a new <see cref="NestedAnimatorEditor"/> to wrap the `animatorProperty`.
        /// </summary>
        public NestedAnimatorEditor(IAnimancerComponent[] targets, SerializedProperty animatorProperty)
        {
            Targets          = targets;
            AnimatorProperty = animatorProperty;
            GatherAnimatorProperties();

            // We need to enforce the expanded state from the Animator property because the Inspector needs to be
            // expanded by Destroy in case the AnimancerComponent is removed (we don't want to leave the Animator
            // collapsed when that happens).
            AnimancerEditorUtilities.SetIsInspectorExpanded(_Animators, animatorProperty.isExpanded);
        }