使用Unity时,读取程序包内部资源的时候,如果使用了www的方法,需要注意在手机平台上的前缀转换.
以下的代码可以获取程序包的目录
public static string AppContentPath() {
string path = string.Empty;
switch (Application.platform) {
case RuntimePlatform.Android:
path = "jar:file://" + Application.dataPath + "!/assets/";
break;
case RuntimePlatform.IPhonePlayer:
path = "file://" + Application.dataPath + "/Raw/";
break;
default:
path = "file://" + Application.dataPath + "/StreamingAssets/";
break;
}
return path;
}
一下代码获取可写的目录
public static string DataPath {
get {
string game = SimpleFramework.AppConst.AppName.ToLower();
if (Application.platform == RuntimePlatform.IPhonePlayer ||
Application.platform == RuntimePlatform.Android ||
Applica