public static T LoadFromTextAsset <T>(TextAsset textAsset, System.Type[] extraTypes = null)
{
if (textAsset == null)
{
throw new ArgumentNullException("textAsset");
}
System.IO.TextReader textStream = null;
try
{
textStream = new System.IO.StringReader(textAsset.text);
XmlSerializer serializer = new XmlSerializer(typeof(T), extraTypes);
T data = (T)serializer.Deserialize(textStream); //T data = (T)serializer...
textStream.Close();
return(data);
}
catch (System.Exception exception)
{
Debug.LogError("The database of type '" + typeof(T) + "' failed to load the asset. The following exception was raised:\n " + exception.Message);
}
finally
{
if (textStream != null)
{
textStream.Close();
}
}
return(default(T));//return default(T);
}