private static bool EnsureAnimationPlayerHasClip(Component animationPlayer)
        {
            bool result;

            if (animationPlayer == null)
            {
                result = false;
            }
            else if (AnimationUtility.GetAnimationClips(animationPlayer.gameObject).Length > 0)
            {
                result = true;
            }
            else
            {
                AnimationClip animationClip = AnimationWindowUtility.CreateNewClip(animationPlayer.gameObject.name);
                if (animationClip == null)
                {
                    result = false;
                }
                else
                {
                    AnimationMode.StopAnimationMode();
                    result = AnimationWindowUtility.AddClipToAnimationPlayerComponent(animationPlayer, animationClip);
                }
            }
            return(result);
        }
        public static bool InitializeGameobjectForAnimation(GameObject animatedObject)
        {
            Component component = AnimationWindowUtility.GetClosestAnimationPlayerComponentInParents(animatedObject.transform);
            bool      result;

            if (component == null)
            {
                AnimationClip animationClip = AnimationWindowUtility.CreateNewClip(animatedObject.name);
                if (animationClip == null)
                {
                    result = false;
                }
                else
                {
                    component = AnimationWindowUtility.EnsureActiveAnimationPlayer(animatedObject);
                    bool flag = AnimationWindowUtility.AddClipToAnimationPlayerComponent(component, animationClip);
                    if (!flag)
                    {
                        UnityEngine.Object.DestroyImmediate(component);
                    }
                    result = flag;
                }
            }
            else
            {
                result = AnimationWindowUtility.EnsureAnimationPlayerHasClip(component);
            }
            return(result);
        }
        private static bool EnsureAnimationPlayerHasClip(Component animationPlayer)
        {
            if ((UnityEngine.Object)animationPlayer == (UnityEngine.Object)null)
            {
                return(false);
            }
            if (AnimationUtility.GetAnimationClips(animationPlayer.gameObject).Length > 0)
            {
                return(true);
            }
            AnimationClip newClip = AnimationWindowUtility.CreateNewClip(animationPlayer.gameObject.name);

            if ((UnityEngine.Object)newClip == (UnityEngine.Object)null)
            {
                return(false);
            }
            AnimationMode.StopAnimationMode();
            return(AnimationWindowUtility.AddClipToAnimationPlayerComponent(animationPlayer, newClip));
        }
        public static bool InitializeGameobjectForAnimation(GameObject animatedObject)
        {
            Component componentInParents = AnimationWindowUtility.GetClosestAnimationPlayerComponentInParents(animatedObject.transform);

            if (!((UnityEngine.Object)componentInParents == (UnityEngine.Object)null))
            {
                return(AnimationWindowUtility.EnsureAnimationPlayerHasClip(componentInParents));
            }
            AnimationClip newClip = AnimationWindowUtility.CreateNewClip(animatedObject.name);

            if ((UnityEngine.Object)newClip == (UnityEngine.Object)null)
            {
                return(false);
            }
            Component animationPlayer          = AnimationWindowUtility.EnsureActiveAnimationPlayer(animatedObject);
            bool      animationPlayerComponent = AnimationWindowUtility.AddClipToAnimationPlayerComponent(animationPlayer, newClip);

            if (!animationPlayerComponent)
            {
                UnityEngine.Object.DestroyImmediate((UnityEngine.Object)animationPlayer);
            }
            return(animationPlayerComponent);
        }