Unity之获取资源包的路径
先从缓存中获取,如果获取不到,则从包中获取。
如下:
public static string GetAssetBundlePath(string path) { // 先尝试从 persist 目录加载 if (GameConfig.HotPatching) { getPathResult.Length = 0; getPathResult.Append(BundleDownloader.Folder); getPathResult.Append("/"); getPathResult.Append(path); tmpPath = getPathResult.ToString(); if (File.Exists(tmpPath)) { getPathResult.Length = 0; getPathResult.Append("file:///"); getPathResult.Append(BundleDownloader.Folder); getPathResult.Append("/"); getPathResult.Append(path); tmpPath = getPathResult.ToString(); return tmpPath; } } #if UNITY_EDITOR || UNITY_STANDALONE_WIN getPathResult.Length = 0; getPathResult.Append("file://"); getPathResult.Append(Application.streamingAssetsPath); getPathResult.Append("/"); getPathResult.Append(path); tmpPath = getPathResult.ToString(); #elif UNITY_IOS getPathResult.Length = 0; getPathResult.Append("file://"); getPathResult.Append(Application.dataPath); getPathResult.Append("/Raw/"); getPathResult.Append(path); tmpPath = getPathResult.ToString(); #elif UNITY_ANDROID getPathResult.Length = 0; getPathResult.Append("jar:file://"); getPathResult.Append(Application.dataPath); getPathResult.Append("!/assets/"); getPathResult.Append(path); tmpPath = getPathResult.ToString(); #endif return tmpPath; }
转载请注明出处:http://www.cnblogs.com/jietian331/p/8631076.html