Пример #1
0
        public static byte[] LoadBytesFile(string fileName, PathHelper.EBytesFileType fileType = PathHelper.EBytesFileType.Table)
        {
            byte[] tmpData         = null;
            string tmpFileFoldName = PathHelper.GetBytesFileFoldNameByType(fileType);

            fileName = $"{tmpFileFoldName}/{fileName}";

            if (GameSetup.instance.IsPublish)
            {
                var tmpResInfo = ResourcesSystem.FindResInfo(fileName);

                switch (tmpResInfo.ResPos)
                {
                case ResourcesSystem.EResPos.Resource:
                {
                    TextAsset tmpTextAsset = Resources.Load <TextAsset>(tmpResInfo.FileHashStr);

                    if (null != tmpTextAsset)
                    {
                        tmpData = tmpTextAsset.bytes;
                    }
                    else
                    {
                        Logger.LogError($"加载bytes文件 {tmpResInfo.FileHashStr} 失败.");
                    }

                    break;
                }

                case ResourcesSystem.EResPos.Persistent:
                {
                    tmpData = ReadFile($"{PathHelper.AppHotfixResPath}/{tmpResInfo.FileHashStr}");
                    break;
                }

                default:
                {
                    Logger.LogError("资源定位错误. bytes文件不可能出现在StreamAsset位置.");
                    break;
                }
                }

                tmpResInfo.Dispose();
            }
            else
            {
                tmpData = ReadFile($"{PathHelper.RUN_TIME_RES_PATH}/{fileName}");
            }

            return(tmpData);
        }
Пример #2
0
        //bundle文件资源路径
        public static string BundleName2ResPath(string bundleName)
        {
            string tmpResPath = AppHotfixResPath;

            if (GameSetup.instance.IsPublish)
            {
                var tmpResInfo = ResourcesSystem.FindResInfo(bundleName);

                switch (tmpResInfo.ResPos)
                {
                case ResourcesSystem.EResPos.StreamAsset:
                {
                    tmpResPath = $"{AppStreamAssetsPath}/{tmpResInfo.FileHashStr}";
                    break;
                }

                case ResourcesSystem.EResPos.Persistent:
                {
                    tmpResPath = $"{AppHotfixResPath}/{tmpResInfo.FileHashStr}";
                    break;
                }

                default:
                {
                    Logger.LogError($"资源定位错误. assetBundle不可能出现在resources位置. name = {bundleName}");
                    break;
                }
                }

                tmpResInfo.Dispose();
            }
            else
            {
                tmpResPath = $"{smNoPublicAssetBundlePath}/{bundleName}";
            }

            return(tmpResPath);
        }