#if !COMBAT_SERVER
using System.IO;
using UnityEngine;
namespace Fort23.Core
{
public static class PathHelper
{
///
///应用程序外部资源路径存放路径(热更新资源路径)
///
public static string AppHotfixResPath
{
get
{
if (!Directory.Exists($"{Application.persistentDataPath}/{Application.identifier}/"))
{
Debug.Log("创建目录:" + $"{Application.persistentDataPath}/{Application.identifier}/");
Directory.CreateDirectory($"{Application.persistentDataPath}/{Application.identifier}/");
}
return $"{Application.persistentDataPath}/{Application.identifier}/";
}
}
///
/// 应用程序内部资源路径存放路径
///
public static string AppResPath
{
get
{
#if UNITY_EDITOR
return Application.streamingAssetsPath;
#elif UNITY_ANDROID
return Application.streamingAssetsPath;
#elif UNITY_IOS
return Application.streamingAssetsPath;
#else
return Application.streamingAssetsPath;
#endif
}
}
///
/// 应用程序内部资源路径存放路径(www/webrequest专用)
///
public static string AppResPath4Web
{
get
{
#if UNITY_IOS || UNITY_STANDALONE_OSX
return $"file://{Application.streamingAssetsPath}";
#else
return Application.streamingAssetsPath;
#endif
}
}
public static string GetWebRequestPath(string resourceName)
{
string p = GetResPath(resourceName);
// webRequest要加file://
if (!p.Contains("://"))
{
p = "file://" + p;
}
return p;
}
///
/// 先从热更路径读取(表示已经热更过),在从内部路径读取(Application.streamingAssetsPath不能用File.Exists判断,无效)
///
///
///
private static string GetResPath(string resourceName)
{
string p = Path.Combine(AppHotfixResPath, resourceName);
if (!File.Exists(p))
{
p = Path.Combine(Application.streamingAssetsPath, resourceName);
}
return p;
}
}
}
#endif