/// <summary>
        /// Unity5下,使用manifest进行AssetBundle的加载
        /// bool isForce,在热更新后,可能需要强制刷新AssetBundleManifest。
        /// </summary>
        public static void PreLoadManifest(bool isForce = false)
        {
            if (_hasPreloadAssetBundleManifest && isForce == false)
            {
                return;
            }

            _hasPreloadAssetBundleManifest = true;
            //此方法不能加载到manifest文件
            //var manifestPath = string.Format("{0}/{1}/{1}.manifest", KResourceModule.BundlesPathRelative,KResourceModule.BuildPlatformName);
            // _mainAssetBundle = AssetBundle.LoadFromFile(manifestPath);
            // _assetBundleManifest = _mainAssetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
            var          manifestPath = KResourceModule.BundlesPathRelative + KResourceModule.GetBuildPlatformName();
            KBytesLoader bytesLoader  = KBytesLoader.Load(manifestPath, LoaderMode.Sync);

            Debuger.Assert(bytesLoader != null, $"load manifest byte error path:{manifestPath}");
            _mainAssetBundle = AssetBundle.LoadFromMemory(bytesLoader.Bytes);
            Debuger.Assert(_mainAssetBundle != null, "load manifest ab error");
            _assetBundleManifest = _mainAssetBundle.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
        }
Exemple #2
0
        /// <summary>
        /// Unity5下,使用manifest进行AssetBundle的加载
        /// bool isForce,在热更新后,可能需要强制刷新AssetBundleManifest。
        /// </summary>
        public static void PreLoadManifest(bool isForce = false)
        {
            if (_hasPreloadAssetBundleManifest && isForce == false)
            {
                return;
            }

            _hasPreloadAssetBundleManifest = true;
            //此方法不能加载到manifest文件
            //var manifestPath = string.Format("{0}/{1}/{1}.manifest", KResourceModule.BundlesPathRelative,KResourceModule.BuildPlatformName);
            // _mainAssetBundle = AssetBundle.LoadFromFile(manifestPath);
            // _assetBundleManifest = _mainAssetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
            KBytesLoader bytesLoader = KBytesLoader.Load(KResourceModule.BundlesPathRelative + KResourceModule.BuildPlatformName, LoaderMode.Sync);

            _mainAssetBundle     = AssetBundle.LoadFromMemory(bytesLoader.Bytes);//KResourceModule.LoadSyncFromStreamingAssets(mainAssetBundlePath));
            _assetBundleManifest = _mainAssetBundle.LoadAsset("AssetBundleManifest") as AssetBundleManifest;

            Debuger.Assert(_mainAssetBundle);
            Debuger.Assert(_assetBundleManifest);
        }