标签:using engine ref pre EDA data unit iter oid
using UnityEngine; using System.Xml.Serialization; using System.IO; public class StateStorage{ public static T LoadData( string key ){ if ( PlayerPrefs.HasKey( key ) ) { XmlSerializer serializer = new XmlSerializer( typeof( T ) ); StringReader sr = new StringReader( PlayerPrefs.GetString( key ) ); return ( T )serializer.Deserialize( sr ); }else{ return default(T); } } public static void SaveData( string key, T source ){ XmlSerializer serializer = new XmlSerializer( typeof( T ) ); StringWriter sw = new StringWriter(); serializer.Serialize( sw, source ); PlayerPrefs.SetString( key, sw.ToString() ); } public static void ClearData( string key ){ PlayerPrefs.DeleteKey( key ); } }
标签:using engine ref pre EDA data unit iter oid
原文地址:https://www.cnblogs.com/allyh/p/11380464.html