12345678910111213141516171819202122232425262728293031323334353637383940 |
- using UnityEngine;
- public class UnityHelper
- {
- /// <summary>
- /// 玩家本地数据存储目录.
- /// </summary>
- /// <returns></returns>
- static public string GetUserDataPath()
- {
- string filepath = Application.persistentDataPath + "\\";
- switch (Application.platform)
- {
- case RuntimePlatform.WindowsPlayer:
- filepath = Application.persistentDataPath + "\\" + System.IO.Path.AltDirectorySeparatorChar;
- break;
- case RuntimePlatform.IPhonePlayer:
- filepath = Application.persistentDataPath + "/";
- break;
- case RuntimePlatform.OSXEditor:
- filepath = Application.persistentDataPath + "/";
- //filepath = Application.dataPath + "/"; // fixed 开发环境时直接放到asset目录下
- break;
- case RuntimePlatform.WindowsEditor:
- filepath = Application.persistentDataPath + "/";
- //filepath = Application.dataPath + "/";
- break;
- case RuntimePlatform.Android:
- filepath = Application.persistentDataPath + "/";
- break;
- default:
- filepath = Application.persistentDataPath + "\\";
- break;
- }
- return filepath;
- }
- }
|