Beispiel #1
0
        //Resource 方式读取
        #region Resources 方式读取

        //加载
        public void Load()
        {
#if UNITY_EDITOR
            if (!string.IsNullOrEmpty(Ext))
            {
                Load(string.Format("{0}/Resources", Application.dataPath), "");
                //失败从StreamingAsset读取
                if (_content == null)
                {
                    if (FileUtil.IsFileExistInStreamingAssets(OriginPath))
                    {
                        byte[] data = FileUtil.ReadFileInStreamingAssets(OriginPath);
                        if (data != null)
                        {
                            OnBinaryLoaded(data);
                        }
                    }
                }
            }
            else
#endif
            {
                _content = ExtResources.Load(Path);
                if (_content == null)
                {
                    JW.Common.Log.LogE("Resource.Load Fail:" + Path);
                }
                else
                {
                    PostProcessContent();
                }
            }
        }
        //判断
        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);
        }