Exemple #1
0
        private void LoadPlatformMainfest(string rootBundlePath, string folerPath, EnciphererKey keyAsset)
        {
            //从内存中加载&解密
            byte[]      datas = Encipherer.AESDecrypt(File.ReadAllBytes(rootBundlePath), keyAsset);
            AssetBundle mainfestAssetBundle = AssetBundle.LoadFromMemory(datas);

            _mainfest = mainfestAssetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");   //
            string[] assetBundleNames = _mainfest.GetAllAssetBundles();
            foreach (var item in assetBundleNames)
            {
                datas = Encipherer.AESDecrypt(File.ReadAllBytes(folerPath + "/" + item), keyAsset);
                AssetBundle assetBundle = AssetBundle.LoadFromMemory(datas);
                string[]    assetNames  = assetBundle.GetAllAssetNames();
                if (assetBundle.isStreamedSceneAssetBundle)
                {
                    assetNames = assetBundle.GetAllScenePaths();
                }
                foreach (var name in assetNames)
                {
                    if (!_allAssets.ContainsKey(name))
                    {
                        _allAssets.Add(name, assetBundle);
                    }
                }
            }
            mainfestAssetBundle.Unload(false);
        }
Exemple #2
0
        //异步加载AssetBundle
        private AssetBundleCreateRequest LoadAssetBundleAsync(string path)
        {
            if (!File.Exists(path))
            {
                throw new Exception("assetbundle not found :" + path);
            }
            AssetBundleCreateRequest assetBundleCreateRequest;

            if (_enciphererkeyAsset != null)
            {
                byte[] datas = Encipherer.AESDecrypt(File.ReadAllBytes(path), _enciphererkeyAsset);
                assetBundleCreateRequest = AssetBundle.LoadFromMemoryAsync(datas);
            }
            else
            {
                assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(path);
            }

            return(assetBundleCreateRequest);
        }
Exemple #3
0
        //同步加载AssetBundle
        private AssetBundle LoadAssetBundle(string path)
        {
            if (!File.Exists(path))
            {
                throw new Exception("assetbundle not found :" + path);
            }

            AssetBundle mainfestAssetBundle;

            if (_enciphererkeyAsset != null)
            {
                byte[] datas = Encipherer.AESDecrypt(File.ReadAllBytes(path), _enciphererkeyAsset);
                mainfestAssetBundle = AssetBundle.LoadFromMemory(datas);
            }
            else
            {
                mainfestAssetBundle = AssetBundle.LoadFromFile(path);
            }


            return(mainfestAssetBundle);
        }