//! //! Saves Animation Data to a XML structure into a file //! public void OnApplicationQuit() { if (Save_Data_to_XML == false || AnimationData.Data.getAnimationClips(gameObject) == null) { return; } List <AnimationClip> clips = AnimationData.Data.getAnimationClips(gameObject); XML_AnimationData runtimeXMLData = new XML_AnimationData(); List <XML_AnimationClip> XMLclipList = new List <XML_AnimationClip>(); foreach (AnimationClip clip in clips) { XML_AnimationClip XMLclip = new XML_AnimationClip(gameObject.name + "_Amimation"); foreach (string property in observedProperties) { List <XML_KeyFrame> XMLkeys = new List <XML_KeyFrame>(); foreach (Keyframe key in AnimationData.Data.getAnimationCurve(clip, property).keys) { XMLkeys.Add(new XML_KeyFrame(key.inTangent, key.outTangent, key.time, key.value, key.tangentMode)); } XML_AnimationCurve XMLcurve = new XML_AnimationCurve(XMLkeys, AnimationData.WrapModeToString(AnimationData.Data.getAnimationCurve(clip, property).postWrapMode), AnimationData.WrapModeToString(AnimationData.Data.getAnimationCurve(clip, property).preWrapMode), "UnityEngine.Transform", property); XMLclip.XML_AnimationCurves.Add(XMLcurve); } XMLclipList.Add(XMLclip); } runtimeXMLData.XML_AnimationClips = XMLclipList; AnimationData.Save(gameObject.name, runtimeXMLData); }
//! //! Returns the System Type a AnimationCurve is working on (saved via XML) //! public System.Type getCurveType(AnimationCurve curve) { XML_AnimationCurve xml = getXMLCurve(curve); if (xml != null) { return(GetTheType(xml.type)); } return(null); }
//! //! Returns the animation property a AnimationCurve is working on (saved via XML) //! public string getCurveProperty(AnimationCurve curve) { XML_AnimationCurve xml = getXMLCurve(curve); if (xml != null) { return(xml.property); } return(null); }
//! //! Add a AnimationCurve to a Clip //! public void addAnimationCurve(AnimationClip clip, System.Type type, string propertyName, AnimationCurve curve) { if (!_animationCurves.ContainsKey(clip)) { _animationCurves.Add(clip, new List <AnimationCurve>()); } _animationCurves[clip].Add(curve); clip.SetCurve(null, type, propertyName, curve); XML_AnimationCurve xmlCurve = new XML_AnimationCurve(type.ToString(), propertyName); addXMLCurve(curve, xmlCurve); }
//! //! Adds a relation between a Unity AnimationCurve and a XML AnimationCurve //! public void addXMLCurve(AnimationCurve curve, XML_AnimationCurve xmlCurve) { _xmlCurves.Add(curve, xmlCurve); }