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 /// /// 热更文件目录 /// private static readonly string _updatePath = _persistentDataPath + "/UpdateAssets"; /// /// 项目的沙盒目录 /// private static readonly string _sandboxPath = _persistentDataPath + "/SandboxAssets"; public static string PersistentDataPath => _persistentDataPath; public static string WorkPath { get { return _streamingAssetsPath; } } /// /// 热更目录 /// 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; } } /// /// 项目的沙盒目录 /// 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; } } } }