Пример #1
0
        public override bool WriteToJson(GameObject gameObject, Component component, MyJson_Object compJson)
        {
            var animation      = component as Animation;
            var animationClips = new List <UnityEngine.AnimationClip>();

            if (animation.clip)
            {
                animationClips.Add(animation.clip);
            }

            var clips = _getAnimationClips(animation);

            if (clips != null && clips.Length > 0)
            {
                foreach (var clip in clips)
                {
                    if (clip == animation.clip)
                    {
                        continue;
                    }

                    animationClips.Add(clip);
                }
            }

            if (animationClips.Count == 0)
            {
                return(false);
            }

            compJson.SetBool("autoPlay", animation.playAutomatically);
            compJson.SetAnimation(gameObject, animationClips.ToArray());
            return(true);
        }
Пример #2
0
        public override bool WriteToJson(GameObject gameObject, Component component, MyJson_Object compJson)
        {
            var aniamtior = component as Animator;

            if (aniamtior.runtimeAnimatorController == null)
            {
                MyLog.Log("缺少runtimeAnimatorController");
                return(false);
            }
            var clips = aniamtior.runtimeAnimatorController.animationClips;

            if (clips == null || clips.Length == 0)
            {
                MyLog.Log("clips为空");
                return(false);
            }

            compJson.SetBool("autoPlay", true); // TODO
            compJson.SetAnimation(gameObject, clips);

            return(true);
        }