AddSpriteAnimationToClip() private static méthode

private static AddSpriteAnimationToClip ( AnimationClip newClip, Object frames ) : void
newClip UnityEngine.AnimationClip
frames Object
Résultat void
        private static bool CreateAnimation(GameObject gameObject, UnityEngine.Object[] frames)
        {
            Array.Sort <UnityEngine.Object>(frames, (UnityEngine.Object a, UnityEngine.Object b) => EditorUtility.NaturalCompare(a.name, b.name));
            bool result;

            if (!AnimationWindowUtility.EnsureActiveAnimationPlayer(gameObject))
            {
                result = false;
            }
            else
            {
                Animator closestAnimatorInParents = AnimationWindowUtility.GetClosestAnimatorInParents(gameObject.transform);
                if (closestAnimatorInParents == null)
                {
                    result = false;
                }
                else
                {
                    AnimationClip animationClip = AnimationWindowUtility.CreateNewClip(gameObject.name);
                    if (animationClip == null)
                    {
                        result = false;
                    }
                    else
                    {
                        SpriteUtility.AddSpriteAnimationToClip(animationClip, frames);
                        result = AnimationWindowUtility.AddClipToAnimatorComponent(closestAnimatorInParents, animationClip);
                    }
                }
            }
            return(result);
        }
Exemple #2
0
        private static bool CreateAnimation(GameObject gameObject, UnityEngine.Object[] frames, SpriteUtility.ShowFileDialogDelegate saveFileDialog)
        {
            SpriteUtility.ShowFileDialogDelegate arg_26_0;
            if ((arg_26_0 = saveFileDialog) == null)
            {
                if (SpriteUtility.< > f__mg$cache1 == null)
                {
                    SpriteUtility.< > f__mg$cache1 = new SpriteUtility.ShowFileDialogDelegate(EditorUtility.SaveFilePanelInProject);
                }
                arg_26_0 = SpriteUtility.< > f__mg$cache1;
            }
            saveFileDialog = arg_26_0;
            Array.Sort <UnityEngine.Object>(frames, (UnityEngine.Object a, UnityEngine.Object b) => EditorUtility.NaturalCompare(a.name, b.name));
            Animator animator = (!AnimationWindowUtility.EnsureActiveAnimationPlayer(gameObject)) ? null : AnimationWindowUtility.GetClosestAnimatorInParents(gameObject.transform);
            bool     flag     = animator != null;
            bool     result;

            if (animator != null)
            {
                string message          = string.Format(SpriteUtility.SpriteUtilityStrings.saveAnimDialogMessage.text, gameObject.name);
                string activeFolderPath = ProjectWindowUtil.GetActiveFolderPath();
                string text             = saveFileDialog(SpriteUtility.SpriteUtilityStrings.saveAnimDialogTitle.text, SpriteUtility.SpriteUtilityStrings.saveAnimDialogName.text, "anim", message, activeFolderPath);
                if (string.IsNullOrEmpty(text))
                {
                    UnityEngine.Object.DestroyImmediate(animator);
                    result = false;
                    return(result);
                }
                AnimationClip animationClip = AnimationWindowUtility.CreateNewClipAtPath(text);
                if (animationClip != null)
                {
                    SpriteUtility.AddSpriteAnimationToClip(animationClip, frames);
                    flag = AnimationWindowUtility.AddClipToAnimatorComponent(animator, animationClip);
                }
            }
            if (!flag)
            {
                Debug.LogError(SpriteUtility.SpriteUtilityStrings.failedToCreateAnimationError.text);
            }
            result = flag;
            return(result);
        }
        private static bool CreateAnimation(GameObject gameObject, UnityEngine.Object[] frames)
        {
            Array.Sort <UnityEngine.Object>(frames, (Comparison <UnityEngine.Object>)((a, b) => EditorUtility.NaturalCompare(a.name, b.name)));
            if (!(bool)((UnityEngine.Object)AnimationWindowUtility.EnsureActiveAnimationPlayer(gameObject)))
            {
                return(false);
            }
            Animator animatorInParents = AnimationWindowUtility.GetClosestAnimatorInParents(gameObject.transform);

            if ((UnityEngine.Object)animatorInParents == (UnityEngine.Object)null)
            {
                return(false);
            }
            AnimationClip newClip = AnimationWindowUtility.CreateNewClip(gameObject.name);

            if ((UnityEngine.Object)newClip == (UnityEngine.Object)null)
            {
                return(false);
            }
            SpriteUtility.AddSpriteAnimationToClip(newClip, frames);
            return(AnimationWindowUtility.AddClipToAnimatorComponent(animatorInParents, newClip));
        }