123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.IO;
- using UnityEngine;
- namespace XGame.Framework.Define
- {
- public static class PathDefine
- {
- private static readonly string _dataPath = Application.dataPath;
- #if UNITY_EDITOR
- private static readonly string _streamingAssetsPath = Environment.CurrentDirectory.Replace("\\", "/") + "/ExtAssets/StreamAssets";
- #else
- private static readonly string _streamingAssetsPath = Application.streamingAssetsPath;
- #endif
- #if UNITY_EDITOR
- private static readonly string _persistentDataPath = Environment.CurrentDirectory.Replace("\\", "/") + "/ExtAssets";
- #elif UNITY_STANDALONE
- private static readonly string _persistentDataPath = Application.dataPath;
- #else
- private static readonly string _persistentDataPath = Application.persistentDataPath;
- #endif
- /// <summary>
- /// 热更文件目录
- /// </summary>
- private static readonly string _updatePath = _persistentDataPath + "/UpdateAssets";
- /// <summary>
- /// 项目的沙盒目录
- /// </summary>
- private static readonly string _sandboxPath = _persistentDataPath + "/SandboxAssets";
- public static string PersistentDataPath => _persistentDataPath;
- public static string WorkPath
- {
- get
- {
- return _streamingAssetsPath;
- }
- }
- /// <summary>
- /// 热更目录
- /// </summary>
- public static string UpdatePath
- {
- get
- {
- var path = _updatePath;
- if (!Directory.Exists(path))
- {
- try
- {
- Directory.CreateDirectory(path);
- }
- catch (Exception ex)
- {
- Log.Error("PathDefine.UpdatePath - Error creating {0}. Exception={1}", path, ex.Message);
- }
- }
- return path;
- }
- }
- /// <summary>
- /// 项目的沙盒目录
- /// </summary>
- public static string SandboxPath
- {
- get
- {
- var path = _sandboxPath;
- if (!Directory.Exists(path))
- {
- try
- {
- Directory.CreateDirectory(path);
- }
- catch (Exception ex)
- {
- Log.Error("PathDefine.SandboxPath - Error creating {0}. Exception={1}", path, ex.Message);
- }
- }
- return path;
- }
- }
- }
- }
|