c# - 如何找到正确的路径以统一保存数据
问题描述
我有一个游戏。每当最终用户退出时,我都应该保存游戏。如何知道在哪里保存?因为如果我将游戏保存到C://Users/..
路径下,如果用户使用Android或IOS会发生什么?这个问题的解决方案是什么?
解决方案
使用根据平台变化的应用程序数据文件夹。
//Attach this script to a GameObject
//This script outputs the Application’s path to the Console
//Run this on the target device to find the application data path for the platform
using UnityEngine;
public class Example : MonoBehaviour
{
string m_Path;
void Start()
{
//Get the path of the Game data folder
m_Path = Application.dataPath;
//Output the Game data path to the console
Debug.Log("dataPath : " + m_Path);
}
}
在这里阅读更多关于它的信息
推荐阅读
- types - 什么是 succ_typings 为 false 的 Dialyzer?
- javascript - 如何通过jquery在文本字段中添加更多值与现有值
- unity3d - Unity不加载项目
- c++ - 将两个数组加在一起并打印到第三个数组中
- c# - 如何从 Visual Studio 中的应用设置中获取价值
- c# - WPF - UserControl - 绑定依赖属性
- arrays - 将来自用户的输入存储为字符数组 C | 分段错误错误
- angular - 从导出功能访问服务时出现问题
- discord - Discord.py 机器人即使被告知不要识别自己的消息
- python - 使用bs4时查找tag和tag