Esempio n. 1
0
        /************************************************************************************************************************/

        /// <summary>
        /// Returns a cached <see cref="AnimationGatherer"/> containing any <see cref="AnimationClip"/>s referenced by
        /// components in the same hierarchy as the `gameObject`. See <see cref="ICharacterRoot"/> for details.
        /// </summary>
        public static AnimationGatherer GatherFromGameObject(GameObject gameObject)
        {
            if (!BeginRecursionGuard(gameObject))
            {
                return(null);
            }

            try
            {
                _CallCount++;
                if (!ObjectToGatherer.TryGetValue(gameObject, out var gatherer))
                {
                    gatherer = new AnimationGatherer();
                    ObjectToGatherer.Add(gameObject, gatherer);
                    gatherer.GatherFromComponents(gameObject);
                }

                return(gatherer);
            }
            catch (Exception exception)
            {
                HandleException(exception);
                return(null);
            }
            finally
            {
                _CallCount--;
                EndCall();
            }
        }
Esempio n. 2
0
            /************************************************************************************************************************/

            public void GatherAnimations()
            {
                AnimationGatherer.GatherFromGameObject(_Instance._Scene.OriginalRoot.gameObject, ref _OtherAnimations, true);

                if (_OtherAnimations.Length > 0 &&
                    (_PreviousAnimation == null || _NextAnimation == null))
                {
                    var defaultClip       = _OtherAnimations[0];
                    var defaultClipIsIdle = false;

                    for (int i = 0; i < _OtherAnimations.Length; i++)
                    {
                        var clip = _OtherAnimations[i];

                        if (defaultClipIsIdle && clip.name.Length > defaultClip.name.Length)
                        {
                            continue;
                        }

                        if (clip.name.IndexOf("idle", StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            defaultClip = clip;
                            break;
                        }
                    }

                    if (_PreviousAnimation == null)
                    {
                        _PreviousAnimation = defaultClip;
                    }
                    if (_NextAnimation == null)
                    {
                        _NextAnimation = defaultClip;
                    }
                }
            }