/// <summary>
/// 根据平台和加载位置,返回资源的完整加载路径
/// </summary>
/// <returns>完整路径.</returns>
/// <param name="name">文件名</param>
/// <param name="path">资源的加载位置</param>
public static string GetLocalURL( string name = "", PathType path = PathType.persistent)
{
string URL = "";
string typePath = "";
try
{
if (path == PathType.persistent)
{
typePath = Application.persistentDataPath;
}
else
{
typePath = Application.streamingAssetsPath;
}
}
catch (Exception e)
{
Debug.LogError(e.ToString());
}
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
URL = "file://" + typePath + "/" + name;
#elif UNITY_ANDROID
URL = typePath + "/"+name;
#elif UNITY_IOS
URL = "file://"+ typePath + "/"+name;
#endif
if (!File.Exists(URL))
{
if (path == PathType.persistent)
{
return GetLocalURL(name, PathType.streaming);
}
else
{
Debug.Log("资源文件不存在:"+name);
}
}
return URL;
} /// <summary>
/// 根据平台和加载位置,返回资源的完整加