问题描述
我的保存系统可以统一使用,但不能在android设备上使用。我不知道为什么不起作用,如何在android设备上安装保存系统。我想这是路径问题。我路径是Application.persistentDataPath +“ /score.data”;是android设备会有其他特定路径还是我的代码有问题。
有我的保存系统代码
using UnityEngine;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
public static class savesystem
{
public static void save(score score)
{
BinaryFormatter formatter = new BinaryFormatter();
string path = Application.persistentDataPath + " /score.data";
FileStream stream = new FileStream(path,FileMode.Create);
Gamedata data = new Gamedata(score);
formatter.Serialize(stream,data);
stream.Close();
}
public static Gamedata Load()
{
string path = Application.persistentDataPath + "/score.data";
if (File.Exists(path))
{
BinaryFormatter formatter = new BinaryFormatter();
FileStream stream = new FileStream(path,FileMode.Open);
Gamedata data =formatter.Deserialize(stream) as Gamedata;
stream.Close();
return data;
}
else
{
Debug.LogError("save file not found in" + path);
return null;
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)