オブジェクト SaveGame をプラグインに送信し、IsolatedStorage に保存することで、ユニティ ゲーム用の dll を作成しようとしています。しかし、それは機能していません。これは、保存に使用されるコードです。
public static void Save(SaveGame filetobeSaved)
{
using (IsolatedStorageFile armz = IsolatedStorageFile.GetUserStoreForApplication())
{
if (armz.FileExists("save.gd"))
{
armz.DeleteFile("save.gd");
}
using (IsolatedStorageFileStream file = new IsolatedStorageFileStream("save.gd", System.IO.FileMode.Create, armz))
{
XmlSerializer serializer = new XmlSerializer(typeof(SaveGame));
serializer.Serialize(file, filetobeSaved);
}} }
IsoStoreSpy を使用してこのファイルを確認すると、ファイルには次のようなものがあります。
<?xml version="1.0" encoding="utf-8"?>
<SaveGame xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
正しく保存されないのはなぜですか?
SaveGame.cs
public class SaveGame
{
public static int gold { get; set; }
public static int BalasMais { get; set; }
public static int DanoMais { get; set; }
public static int SpeedMais { get; set; }
public static int LifeMais { get; set; }
public int getGold() { return gold; }
public int getBalas() { return BalasMais; }
public int getDano() { return DanoMais; }
public int getSpeed() { return SpeedMais; }
public int getLife() { return LifeMais; }
public SaveGame()
{
gold = 0;
BalasMais = 0;
DanoMais = 0;
SpeedMais = 0;
LifeMais = 0;
}
public SaveGame(int g, int b, int d, int s, int l)
{
gold = g;
BalasMais = b;
DanoMais = d;
SpeedMais = s;
LifeMais = l;
}
}
}