Пример #1
0
        //!
        //! Loads Animation Data from File if they have been saved before
        //!
        public void loadData()
        {
            if (Load_Data_from_XML)
            {
                XML_Data = AnimationData.Load(name);

                if (XML_Data == null)
                {
                    return;
                }

                foreach (XML_AnimationClip XMLclip in XML_Data.XML_AnimationClips)
                {
                    XMLclip.data = new AnimationClip();
                    AnimationData.Data.addAnimationClip(gameObject, XMLclip.data);
                    foreach (XML_AnimationCurve XMLcurve in XMLclip.XML_AnimationCurves)
                    {
                        // print( "XMLcurve " + XMLcurve.property );

                        XMLcurve.data = new AnimationCurve();
                        foreach (XML_KeyFrame XMLkey in XMLcurve.XML_KeyFrames)
                        {
                            XMLkey.data = new Keyframe(XMLkey.t, XMLkey.v, XMLkey.inT, XMLkey.outT);
                            XMLcurve.data.AddKey(XMLkey.data);


                            timeStart = Mathf.Min(timeStart, XMLkey.t);
                            timeEnd   = Mathf.Max(XMLkey.t, timeEnd);
                        }
                        XMLcurve.data.postWrapMode = AnimationData.StringToWrapMode(XMLcurve.postWM);
                        XMLcurve.data.preWrapMode  = AnimationData.StringToWrapMode(XMLcurve.preWM);
                        System.Type type = AnimationData.GetTheType(XMLcurve.type);
                        AnimationData.Data.addAnimationCurve(XMLclip.data, type, XMLcurve.property, XMLcurve.data);
                    }
                }

                //register the object in the animation Controller
                GameObject.Find("AnimationController").GetComponent <AnimationController>().registerAnimatedObject(gameObject.GetComponent <SceneObject>());

                gameObject.GetComponent <SceneObject>().setKinematic(true, false);
            }
        }
        //!
        //! Loads Animation Data from File if they have been saved before
        //!
        public bool loadData()
        {
            if (Load_Data_from_XML)
            {
                XML_Data = AnimationData.Load(name);

                if (XML_Data == null)
                {
                    return(false);
                }

                foreach (XML_AnimationClip XMLclip in XML_Data.XML_AnimationClips)
                {
                    XMLclip.data = new AnimationClip();
                    AnimationData.Data.addAnimationClip(gameObject, XMLclip.data);
                    foreach (XML_AnimationCurve XMLcurve in XMLclip.XML_AnimationCurves)
                    {
                        // print( "XMLcurve " + XMLcurve.property );

                        XMLcurve.data = new AnimationCurve();
                        foreach (XML_KeyFrame XMLkey in XMLcurve.XML_KeyFrames)
                        {
                            XMLkey.data = new Keyframe(XMLkey.t, XMLkey.v, XMLkey.inT, XMLkey.outT);
                            XMLcurve.data.AddKey(XMLkey.data);
                        }
                        XMLcurve.data.postWrapMode = AnimationData.StringToWrapMode(XMLcurve.postWM);
                        XMLcurve.data.preWrapMode  = AnimationData.StringToWrapMode(XMLcurve.preWM);
                        System.Type type = AnimationData.GetTheType(XMLcurve.type);
                        AnimationData.Data.addAnimationCurve(XMLclip.data, type, XMLcurve.property, XMLcurve.data);
                    }
                }

                return(true);
            }
            return(false);
        }