示例#1
0
        /// <summary>
        /// 从指定目录加载二进制资源
        /// </summary>
        /// <param name="directory">目录</param>
        void Load(string directory, string pkgPath)
        {
            string fullPath = FileUtil.CombinePath(directory, OriginPath);

            byte[] data = FileUtil.ReadFile(fullPath);
            if (data != null)
            {
                OnBinaryLoaded(data);
            }
        }
示例#2
0
        /// <summary>
        /// 从IFS或StreamingAssets目录异步加载资源
        /// </summary>
        /// <param name="complete"></param>
        /// <param name="progress"></param>
        /// <returns></returns>
        public IEnumerator LoadAsync(string pkgPath, bool outside, Action <ResObj> complete = null, Action <float> progress = null)
        {
            string realPath = FileUtil.CombinePath(pkgPath, OriginPath);

            if (outside)
            {
                yield return(LoadAsync(FileUtil.GetIFSExtractPathWithHeader(), pkgPath, complete, progress));
            }
            else
            {
                yield return(LoadAsync(FileUtil.GetStreamingAssetsPathWithHeader(""), pkgPath, complete, progress));
            }
        }
        /// <summary>
        /// 取bundle完整路径
        /// </summary>
        /// <param name="pi"></param>
        /// <returns></returns>
        string GetBundleFullPath(BundlePackInfo pi, bool withHeader)
        {
#if UNITY_EDITOR && !UNITY_EDITOR_OSX
            // 在PC上用Windows的Shader包,解决材质丢失问题
            if (pi.Path == "Shaders.ab")
            {
                if (withHeader)
                {
                    return(string.Format("file:///{0}/../../IFS/Build/Win/shaders.ab", Application.dataPath));
                }
                else
                {
                    return(string.Format("{0}/../../IFS/Build/Win/shaders.ab", Application.dataPath));
                }
            }
            else
#endif
            {
                if (pi.Outside)
                {
                    if (withHeader)
                    {
                        return(FileUtil.CombinePath(FileUtil.GetIFSExtractPathWithHeader(), pi.Path));
                    }
                    else
                    {
                        return(FileUtil.CombinePath(FileUtil.GetIFSExtractPath(), pi.Path));
                    }
                }
                else
                {
                    if (withHeader)
                    {
                        return(FileUtil.GetStreamingAssetsPathWithHeader(pi.Path));
                    }
                    else
                    {
                        return(FileUtil.CombinePath(Application.streamingAssetsPath, pi.Path));
                    }
                }
            }
        }
示例#4
0
        //判断
        public bool IsBinaryResourceExsitInPkg(string Path)
        {
            string      noExtPath = FileUtil.EraseExtension(Path);
            ResPackInfo packInfo  = GetResPackInfo(noExtPath);

            if (packInfo != null)
            {
                if (packInfo.GetPackType() == (byte)ResPackType.ResPackTypeBinary)
                {
                    string realPath = FileUtil.CombinePath(packInfo.Path, Path);

                    if (FileUtil.IsExistInIFSExtraFolder(realPath) || FileUtil.IsFileExistInStreamingAssets(realPath))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#5
0
        /// <summary>
        /// 从IFS或StreamingAssets目录同步加载资源
        /// </summary>
        public void Load(string pkgPath, bool outside)
        {
            if (outside)
            {
                Load(FileUtil.GetIFSExtractPath(), pkgPath);
            }
            else
            {
                // load from StreamingAssets
#if UNITY_ANDROID && !UNITY_EDITOR
                string realPath = FileUtil.CombinePath(pkgPath, OriginPath);
                byte[] data     = NativeUtil.Android_ReadFileInAssets(realPath);
                if (data != null)
                {
                    OnBinaryLoaded(data);
                }
#else
                Load(FileUtil.GetStreamingAssetsPath(), pkgPath);
#endif
            }
        }
示例#6
0
 /// <summary>
 /// 文件是否存在于StreamingAssets目录下
 /// </summary>
 /// <param name="fileName"></param>
 /// <returns></returns>
 public static bool IsFileExistInStreamingAssets(string fileName)
 {
     return(FileUtil.IsFileExist(FileUtil.CombinePath(Application.streamingAssetsPath, fileName)));
 }