Exemplo n.º 1
0
        public override JSONComponent ToJSON()
        {
            var json = new JSONAnimation();

            json.type  = "Animation";
            json.clips = new JSONAnimationClip[clips.Count];

            for (int i = 0; i < clips.Count; i++)
            {
                JEAnimationClip clip = clips[i];

                var jclip = json.clips[i] = new JSONAnimationClip();

                jclip.name   = clip.name;
                jclip.length = clip.length;

                JSONAnimationNode[] jnodes = jclip.nodes = new JSONAnimationNode[clip.keyframes.Count];

                int count = 0;
                foreach (KeyValuePair <string, List <JEKeyframe> > entry in clip.keyframes)
                {
                    JSONAnimationNode node = new JSONAnimationNode();
                    node.name      = entry.Key;
                    node.keyframes = new JSONKeyframe[entry.Value.Count];

                    int kcount = 0;
                    foreach (var key in entry.Value)
                    {
                        var jkeyframe = new JSONKeyframe();

                        if (string.IsNullOrEmpty(key.name))
                        {
                            jkeyframe.value = key.value;
                        }
                        else
                        {
                            jkeyframe.name = key.name;
                        }

                        jkeyframe.time = key.time;

                        if (node.name == "m_IsActive")
                        {
                            jkeyframe.onOff = true;
                        }
                        else
                        {
                            jkeyframe.onOff = key.onOff;
                        }

                        node.keyframes[kcount++] = jkeyframe;
                    }

                    jnodes[count++] = node;
                }
            }

            return(json);
        }
Exemplo n.º 2
0
        public override JSONComponent ToJSON()
        {
            var json = new JSONAnimation();

            json.type = "Animation";

            json.clips = new JSONAnimationClip[clips.Count];

            for (int i = 0; i < clips.Count; i++)
            {
                JEAnimationClip clip = clips[i];

                var jclip = json.clips[i] = new JSONAnimationClip();

                jclip.name = clip.name;

                JSONAnimationNode[] jnodes = jclip.nodes = new JSONAnimationNode[clip.keyframes.Count];

                int count = 0;
                foreach (KeyValuePair <string, List <JEKeyframe> > entry in clip.keyframes)
                {
                    JSONAnimationNode node = new JSONAnimationNode();
                    node.name      = entry.Key;
                    node.keyframes = new JSONKeyframe[entry.Value.Count];

                    int kcount = 0;
                    foreach (var key in entry.Value)
                    {
                        var jkeyframe = new JSONKeyframe();

                        jkeyframe.pos   = key.pos;
                        jkeyframe.scale = key.scale;
                        jkeyframe.rot   = key.rot;

                        jkeyframe.time = key.time;

                        node.keyframes[kcount++] = jkeyframe;
                    }

                    jnodes[count++] = node;
                }
            }

            return(json);
        }