I'm working on a dll for Unity. The code is to save the name and location of gameObject in an xml file. If the class is public, it works smoothly, but I volgio static. Only that static can not serialize it.
Can you help me?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using System.IO;
using System.Xml.Serialization;
namespace SaveSystemXML
{
static class SaveSystem
{
private static string name;
private static Vector3 pos;
private static string path = "savingDati.txt";
public static string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public static Vector3 Pos
{
get
{
return pos;
}
set
{
pos = value;
}
}
public static void SaveInfo(Transform m_hInfo)
{
name = m_hInfo.name;
pos = m_hInfo.transform.position;
if (!File.Exists(path))
{
using (var file = new FileStream(path, FileMode.Create))
{
var XML = new XmlSerializer(typeof(SaveSystem));
XML.Serialize(file, this); //this error because is a static class
}
}
}
}
}