zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Python 面向对象(初级篇)
    python中的运算符
    初识Python
    浅谈计算机
    Zeppelin interperter 模式设置总结图解2
    maven 使用错误
    TensorFlow anaconda命令备忘
    zeppelin ERROR总结
    YARN 命令总结
    Zeppelin interperter 模式设置总结图解1
  • 原文地址:https://www.cnblogs.com/jietian331/p/8631076.html
Copyright © 2011-2022 走看看