美文网首页
Unity 获取 AB 源文件路径(打包进安装包的)

Unity 获取 AB 源文件路径(打包进安装包的)

作者: _灯下影子 | 来源:发表于2021-07-07 16:35 被阅读0次
    /// <summary>
            /// 获取 AB 源文件路径(打包进安装包的)
            /// </summary>
            /// <param name="path"></param>
            /// <param name="forWWW"></param>
            /// <returns></returns>
            public static string GetBundleSourceFile(string path, bool forWWW = true)
            {
                string filePath = null;
    #if UNITY_EDITOR
                if (forWWW)
                    filePath = string.Format("file://{0}/StreamingAssets/{1}/{2}", Application.dataPath, BundleSaveDirName,
                        path);
                else
                    filePath = string.Format("{0}/StreamingAssets/{1}/{2}", Application.dataPath, BundleSaveDirName, path);
    #elif UNITY_STANDALONE_WIN
                if (forWWW)
                    filePath =
     string.Format("file://{0}/StreamingAssets/{1}/{2}", Application.dataPath, BundleSaveDirName, path);
                else
                    filePath = string.Format("{0}/StreamingAssets/{1}/{2}", Application.dataPath, BundleSaveDirName, path);
    #elif UNITY_ANDROID
                if (forWWW)
                    filePath =
     string.Format("jar:file://{0}!/assets/{1}/{2}", Application.dataPath, BundleSaveDirName, path);
                else
                    filePath = string.Format("{0}!assets/{1}/{2}", Application.dataPath, BundleSaveDirName, path);
    #elif UNITY_IOS
                if (forWWW)
                    filePath = string.Format("file://{0}/Raw/{1}/{2}", Application.dataPath, BundleSaveDirName, path);
                else
                    filePath = string.Format("{0}/Raw/{1}/{2}", Application.dataPath, BundleSaveDirName, path);
    #else
                throw new System.NotImplementedException();
    #endif
                // LuaInterface.Debugger.Log(string.Format("{1}:[{0}]", filePath, "filePath34445"));
    
                return filePath;
            }
    

    相关文章

      网友评论

          本文标题:Unity 获取 AB 源文件路径(打包进安装包的)

          本文链接:https://www.haomeiwen.com/subject/jszoultx.html