/// <summary>
        /// Fills the `clips` with any <see cref="AnimationClip"/>s referenced by components in the same hierarchy as
        /// the `gameObject`. See <see cref="ICharacterRoot"/> for details.
        /// </summary>
        public static void GatherFromGameObject(GameObject gameObject, ref AnimationClip[] clips, bool sort)
        {
            if (!BeginRecursionGuard(gameObject))
            {
                return;
            }

            try
            {
                _CallCount++;

                var clipSet = ObjectPool.AcquireSet <AnimationClip>();

                GatherFromComponents(gameObject, clipSet);

                if (clips == null || clips.Length != clipSet.Count)
                {
                    clips = new AnimationClip[clipSet.Count];
                }

                clipSet.CopyTo(clips);
                ObjectPool.Release(clipSet);

                if (sort)
                {
                    Array.Sort(clips, (a, b) => a.name.CompareTo(b.name));
                }
            }
            finally
            {
                _CallCount--;
                EndCall();
            }
        }
            /************************************************************************************************************************/

            /// <summary>
            /// Determines the <see cref="MatchType"/> representing the properties animated by the `state` in
            /// comparison to the properties that actually exist on the target <see cref="GameObject"/> and its
            /// children.
            /// <para></para>
            /// Also compiles a `message` explaining the differences if that paraneter is not null.
            /// </summary>
            public MatchType GetMatchType(AnimancerState state, StringBuilder message)
            {
                var clips = ObjectPool.AcquireSet <AnimationClip>();

                state.GatherAnimationClips(clips);

                var bindings         = message != null ? new Dictionary <EditorCurveBinding, bool>() : null;
                var existingBindings = 0;

                MatchType match = default;

                foreach (var clip in clips)
                {
                    var clipMatch = GetMatchType(clip, message, bindings, ref existingBindings);
                    if (match < clipMatch)
                    {
                        match = clipMatch;
                    }
                }

                AppendBindings(message, bindings, existingBindings);

                ObjectPool.Release(clips);
                return(match);
            }
        /************************************************************************************************************************/

        /// <summary>
        /// Fills the `clips` with any <see cref="AnimationClip"/>s referenced by components in the same hierarchy as
        /// the `gameObject`. See <see cref="ICharacterRoot"/> for details.
        /// </summary>
        public static void GatherFromGameObject(GameObject gameObject, ICollection <AnimationClip> clips)
        {
            if (!BeginRecursionGuard(gameObject))
            {
                return;
            }

            try
            {
                _CallCount++;

                var clipSet = clips as HashSet <AnimationClip>;
                if (clipSet == null)
                {
                    clipSet = ObjectPool.AcquireSet <AnimationClip>();
                }

                GatherFromComponents(gameObject, clipSet);

                if (clipSet != clips)
                {
                    clips.Gather(clipSet);
                    ObjectPool.Release(clipSet);
                }
            }
            finally
            {
                _CallCount--;
                EndCall();
            }
        }
Пример #4
0
        /************************************************************************************************************************/
        #endregion
        /************************************************************************************************************************/

        /// <summary>
        /// Fills the `clips` with any <see cref="AnimationClip"/>s referenced by components in the same hierarchy as
        /// the `gameObject`. See <see cref="ICharacterRoot"/> for details.
        /// </summary>
        public static void GatherFromGameObject(GameObject gameObject, ICollection <AnimationClip> clips)
        {
            if (!BeginRecursionGuard(gameObject))
            {
                return;
            }

            try
            {
                _CallCount++;
                HashSet <AnimationClip> clipSet;
                if (!ObjectToClips.TryGetValue(gameObject, out clipSet))
                {
                    clipSet = ObjectPool.AcquireSet <AnimationClip>();
                    GatherFromComponents(gameObject, clipSet);
                    ObjectToClips.Add(gameObject, clipSet);
                }

                clips.Gather(clipSet);
            }
            finally
            {
                _CallCount--;
                EndCall();
            }
        }
Пример #5
0
        /************************************************************************************************************************/

        /// <summary>
        /// Uses <see cref="HandleDragAndDrop"/> to deal with drag and drop operations involving
        /// <see cref="AnimationClip"/>s of <see cref="IAnimationClipSource"/>s.
        /// </summary>
        public static void HandleDragAndDropAnimations(Rect dropArea, Action <AnimationClip> onDrop)
        {
            HandleDragAndDrop(dropArea, (clip) => !clip.legacy, onDrop);

            HandleDragAndDrop <IAnimationClipSource>(dropArea, null, (source) =>
            {
                var clips = ObjectPool.AcquireList <AnimationClip>();
                source.GetAnimationClips(clips);
                TryDrop(clips, (clip) => !clip.legacy, onDrop, true);
                ObjectPool.Release(clips);
            });

            HandleDragAndDrop <IAnimationClipCollection>(dropArea, null, (collection) =>
            {
                var clips = ObjectPool.AcquireSet <AnimationClip>();
                collection.GatherAnimationClips(clips);
                TryDrop(clips, (clip) => !clip.legacy, onDrop, true);
                ObjectPool.Release(clips);
            });
        }