public static AEAnimationData ParceAnimationData(string data)
    {
        #if !UNITY_WEBPLAYER

        XDocument xmlDoc = XDocument.Load(new StringReader(data));

        AEAnimationData animation = new AEAnimationData ();

        XElement meta_element 	=  xmlDoc.Root.Element ("meta");//xmlDoc.Root == after_affect_animation_doc
        animation.frameDuration =  GetFloat(meta_element.Attribute("frameDuration").Value);
        animation.totalFrames 	=  GetInt(meta_element.Attribute("totalFrames").Value);
        animation.duration	 	=  GetFloat(meta_element.Attribute("duration").Value);

        frameDuration = animation.frameDuration;

        foreach (XElement element in xmlDoc.Root.Elements()) {//xmlDoc.Root == after_affect_animation_doc
            switch(element.Name.ToString()) {
                case "composition":
                    animation.composition = ParseComposition (element);
                    break;
                case "sub_items":
                    foreach (XElement sub_element in element.Elements()) {
                        animation.addComposition(ParseComposition (sub_element));
                    }
                    break;
            }
        }

        return animation;
        #else
        return null;
        #endif
    }
Esempio n. 2
0
    public static AEAnimationData ParceAnimationData(string data)
    {
        XmlDocument doc =  new XmlDocument();
        doc.LoadXml(data);

        AEAnimationData animation = new AEAnimationData ();

        XmlNode anim = doc.SelectSingleNode("after_affect_animation_doc");

        XmlNode meta = anim.SelectSingleNode("meta");
        animation.frameDuration = GetFloat (meta, "frameDuration");
        animation.totalFrames = GetInt (meta, "totalFrames");
        animation.duration =  GetFloat (meta, "duration");

        frameDuration = animation.frameDuration;

        XmlNode composition = anim.SelectSingleNode("composition");
        animation.composition = ParseComposition (composition);

        XmlNode sub_items = anim.SelectSingleNode("sub_items");
        XmlNodeList usedCompositions = sub_items.SelectNodes("composition");

        foreach (XmlNode c in usedCompositions) {
            animation.addComposition(ParseComposition (c));
        }

        return animation;
    }
    public virtual void OnAnimationDataChange()
    {
        if(dataFile != null) {
            gameObject.name = "AE " + dataFile.name;

            #if !UNITY_WEBPLAYER
            _animationData = AEDataParcerWP8.ParceAnimationData (dataFile.text);
            #else
            _animationData = AEDataParcer.ParceAnimationData (dataFile.text);
            #endif

            InitSprites ();
        }

        timeScale = 1f;
        OnPivotPositionChnage ();
        SetColor(MaterialColor);

        int f = currentFrame;
        currentFrame = 0;
        OnEditorFrameChange();
        currentFrame = f;
        OnEditorFrameChange();
    }