Esempio n. 1
0
        static AssetBundleManager()
        {
            var    setting = Resources.Load <AssetBundleManagerSetting>(AssetBundleManagerSettingName);
            string manifestBundleName;

            if (setting)
            {
                mHasBundleExtension  = setting.TryGetBundleExtension(out mBundleExtension);
                manifestBundleName   = Path.GetFileNameWithoutExtension(setting.BuildBundlePath);
                mAssetBundleRootPath = setting.GetLoadBundleFullPath();
                Resources.UnloadAsset(setting);
            }
            else
            {
                mHasBundleExtension  = false;
                mBundleExtension     = null;
                manifestBundleName   = string.Empty;
                mAssetBundleRootPath = string.Empty;
                Debug.LogError("Null AssetBundleManagerSetting!");
            }

            //Load AssetBundleManifest
            var manifestBundle = AssetBundle.LoadFromFile(GetAssetBundlePath(manifestBundleName, false));

            if (!manifestBundle)
            {
                Debug.LogError($"Load ManifestBundle {manifestBundleName} error: Null AssetBundle!");
            }
            else
            {
                Manifest = manifestBundle.LoadAsset <AssetBundleManifest>(nameof(AssetBundleManifest));
                if (!Manifest)
                {
                    Debug.LogError($"Load AssetBundleManifest error: Null Asset!");
                }
                manifestBundle.Unload(false);
            }
        }
Esempio n. 2
0
    /// <summary>
    /// 获取总的Manifest
    /// </summary>
    /// <param name="manifestPath">总的Manifest路径</param>
    /// <returns></returns>
    public IEnumerator GetManifest(string manifestPath)
    {
        //下载资源列表到外部路径
        using (WWW wwwManifest = new WWW(manifestPath))
        {
            yield return(wwwManifest);

            if (!string.IsNullOrEmpty(wwwManifest.error))
            {
                if (Debug.developerConsoleVisible)
                {
                    Debug.Log("获取AssetBundleManifest出错!");
                }
            }
            else
            {
                AssetBundle manifestBundle = wwwManifest.assetBundle;
                manifest = manifestBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");    //获取总的Manifest
                manifestBundle.Unload(false);
                GetBundleNamesAndHashID();
            }
        }
    }
    private IEnumerator GetAssetBundleManifest(string uri)
    {
        while (!Caching.ready)
        {
            yield return(null);
        }
        UnityWebRequest bundleWebRequest = UnityWebRequestAssetBundle.GetAssetBundle(uri);

        yield return(bundleWebRequest.SendWebRequest());

        if (bundleWebRequest.isHttpError)
        {
            yield break;
        }
        else
        {
            AssetBundle manifestBundle = DownloadHandlerAssetBundle.GetContent(bundleWebRequest);

            AssetBundleManifest manifest = manifestBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
            this.manifest = manifest;
            bundleWebRequest.Dispose();
        }
    }
Esempio n. 4
0
        /// <summary>
        /// 加载Manifest清单文件
        /// </summary>
        /// <returns></returns>
        public IEnumerator LoadManifestFile()
        {
            using (UnityWebRequest www = UnityWebRequest.Get(_StrManifestPath))
            {
                yield return(www.SendWebRequest());

                if (www.isDone)
                {
                    AssetBundle abObj = AssetBundle.LoadFromMemory(www.downloadHandler.data);
                    if (abObj != null)
                    {
                        Debug.Log("加载完成");
                        _ABReadManifest = abObj;
                        _ManifestObj    = _ABReadManifest.LoadAsset(ABDefine.ASSETBUNDLW_MANIFEST) as AssetBundleManifest;
                        _IsLoadFinish   = true;
                    }
                    else
                    {
                        Debug.LogError("abObj == null");
                    }
                }
            }
        }
Esempio n. 5
0
    public IEnumerator LoadManifest()
    {
        //这里获取到了文件的路径
        assetManifestName = IPathTools.StandardPath(assetManifestName);

        WWW manifest = new WWW(assetManifestName);

        yield return(manifest);

        if (string.IsNullOrEmpty(manifest.error))
        {
            if (manifest.progress >= 1.0)
            {
                manifestloader      = manifest.assetBundle;
                assetBundleManifest = manifestloader.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
                isFinishedLoad      = true;
            }
        }
        else
        {
            Debug.LogError(manifest.error);
        }
    }
Esempio n. 6
0
        IEnumerator EnumLoadABManifestAsync()
        {
            if (string.IsNullOrEmpty(assetBundleManifestName))
            {
                //TODO 协程异常 resMgr
                //throw new CFrameworkException("AssetBundle Manifest name empty , please reset abManifest !");
                Utility.Assert.NotNull(assetBundleManifestName);
            }
            else
            {
                if (assetBundleManifest == null)
                {
                    yield return(Facade.StartCoroutine(EnumLoadABAsync(assetBundleManifestName, true)));

                    if (HasAssetBundle(assetBundleManifestName))
                    {
                        assetBundleManifest = assetBundleDict[assetBundleManifestName].LoadAsset <AssetBundleManifest>("AssetBundleManifest");
                        UnloadAsset(assetBundleManifestName);
                    }
                }
            }
            yield return(null);
        }
Esempio n. 7
0
        /// <summary>
        /// 下载peresistent文件夹下的manifest文件
        /// </summary>
        /// <param name="assetBundleName">Asset bundle name.</param>
        private void LoadPeresistentManifest(string assetBundleName, string assetName)
        {
            string path = Path.Combine(Utility.PersistentPath(), assetBundleName);

            if (!File.Exists(path))
            {
                return;
            }

            AssetBundle bundle = AssetBundle.LoadFromFile(path);

            if (bundle == null)
            {
                string error = "Failed to load persistent manifest !";
                this.operation.isError = true;
                this.operation.error   = error;
                Debug.LogError(error);
                return;
            }

            this.peresistent_manifest = bundle.LoadAsset <AssetBundleManifest>(assetName);
            bundle.Unload(false);
        }
Esempio n. 8
0
        /// <summary>
        /// 首先打包AssetBundle到缓存发布目录
        /// </summary>
        void BuildAssetBundlesToCacheDir()
        {
            AssetBundleBuild[] abbList = new AssetBundleBuild[_abDic.Count];
            int i = 0;

            foreach (var abb in _abDic)
            {
                abbList[i] = new AssetBundleBuild();
                abbList[i].assetBundleName = abb.Key;
                abbList[i].assetNames      = abb.Value.ToArray();
                i++;
            }

            if (false == Directory.Exists(ZeroEditorConst.ASSET_BUNDLE_CACHE_DIR))
            {
                Directory.CreateDirectory(ZeroEditorConst.ASSET_BUNDLE_CACHE_DIR);
            }

            assetBundleManifest = BuildPipeline.BuildAssetBundles(ZeroEditorConst.ASSET_BUNDLE_CACHE_DIR, abbList, BuildAssetBundleOptions.ChunkBasedCompression | BuildAssetBundleOptions.DeterministicAssetBundle, ZeroEditorConst.BUILD_PLATFORM);

            //清理不再需要的资源(需要修改算法,只保留需要的,完全清理不需要的资源)
            CleanCahceDir();
        }
Esempio n. 9
0
        private static void FillBundleInfo(AssetBundleManifest manifest, string name, byte[] bytes, ref VersionInfo versionInfo)
        {
            var bundleInfo = new BundleInfo();

            // write assetbundle normal infomation
            bundleInfo.Name = name;
            bundleInfo.Size = bytes.Length;
            MD5 md5 = new MD5CryptoServiceProvider();

            bundleInfo.Md5Code      = Convert.ToBase64String(md5.ComputeHash(bytes));
            bundleInfo.Dependencies = manifest.GetAllDependencies(name);

            // relate assetbundle name with asset path
            var assetBundle = AssetBundle.LoadFromMemory(bytes);

            foreach (var content in assetBundle.GetAllAssetNames())
            {
                versionInfo.BundlePath.Add(content, name);
            }
            assetBundle.Unload(true);
            // add bundleInfo to versionInfo
            versionInfo.Bundles.Add(bundleInfo);
        }
Esempio n. 10
0
        /// <summary> 初始化,获取manifest的信息 </summary>
        public void Initialize()
        {
#if UNITY_EDITOR
            if (GameConfigProject.instance.assetLoadType == (int)GameConfigProject.LoadType.SimulateEditor)
            {//模拟AssetBundle
                return;
            }
#endif
            Debug.Log(string.Format("初始化AssetBundle: {0}", DataConfigProject.platform));
            LoadedAssetBundle assetBundle;
            if (mLoadedAssetBundleDic.TryGetValue("asset_bundle_manifest", out assetBundle))
            {
                if (assetBundle.assetBundle != null)
                {
                    assetBundle.UnloadAssetBundle(true);
                }
                assetBundle.Reset();
                mLoadedAssetBundleDic.Remove("asset_bundle_manifest");
            }
            assetBundle = GetOrGenerateLoadedAssetBundle("asset_bundle_manifest", true, false);
            mGameFullAssetBundleManifest = assetBundle.GetAsset("AssetBundleManifest", false) as AssetBundleManifest;
            // Debug.Log(string.Format("初始化AssetBundle完成: {0}", DataConfigProject.platform));
        }
        public static void Combine()
        {
            int           count = MANIFESTS.Count;
            List <string> ns    = new List <string>();
            List <string> vs    = new List <string>();

            for (int i = 0; i < count; i++)
            {
                AssetBundleManifest manifest        = MANIFESTS[i];
                string[]            allAssetBundles = manifest.GetAllAssetBundles();
                string[]            allVariants     = manifest.GetAllAssetBundlesWithVariant();
                ns.AddRange(allAssetBundles);
                vs.AddRange(allVariants);
                foreach (string n in allAssetBundles)
                {
                    DEPENDENCIES[n] = manifest.GetAllDependencies(n);
                    HASHS[n]        = manifest.GetAssetBundleHash(n);
                }
            }
            _bundles  = ns.ToArray();
            _variants = vs.ToArray();
            MANIFESTS.Clear();
        }
Esempio n. 12
0
    /// <summary>
    /// 加载 AssetBundleManifest 文件
    /// </summary>
    /// <returns></returns>
    public IEnumerator LoadAssetBundleManifest(Action callback = null)
    {
        WWW www = new WWW(manifestPath);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError(www.error);
        }
        else
        {
            if (www.progress >= 1.0f)
            {
                assetBundle = www.assetBundle;

                maniFest = assetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");

                isLoadFinished = true;
                Debug.Log("加载AssetBundleManifest文件完成");
            }
        }
    }
    public IEnumerator LoadManifest()
    {
        Debug.Log("manifestPath = " + manifestPath);
        WWW manifestWWW = new WWW(manifestPath);

        yield return(manifestWWW);

        if (!string.IsNullOrEmpty(manifestWWW.error))
        {
            // 报错
            Debug.LogWarning(manifestWWW.error);
        }
        else
        {
            // 加载成功
            if (manifestWWW.progress >= 1.0f)
            {
                manifestLoader = manifestWWW.assetBundle;
                assetManifest  = manifestLoader.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
                isLoadFinish   = true;
            }
        }
    }
        /// <summary>
        /// 下载 Manifest 清单文件
        /// </summary>
        /// <returns></returns>
        public IEnumerator LoadManifest()
        {
            using (WWW www = new WWW(_StrManifestPath)) {
                yield return(www);

                if (www.progress >= 1)
                {
                    // 加载完成,获取 AssetBundle 实例
                    AssetBundle abObj = www.assetBundle;
                    if (abObj != null)
                    {
                        _ABReadManifest = abObj;
                        //  读取清单文件资源(读取到系统类的实例中)
                        _ManifestObj    = _ABReadManifest.LoadAsset(ABDefine.ASSETBUNDLE_MANIFEST) as AssetBundleManifest; // 字符串 AssetBundleManifest 是固定常量
                        _IsLoadFinished = true;
                    }
                    else
                    {
                        Debug.LogError(GetType() + "/ LoadManifest() / WWW 下载出错,请检查下载路径 _StrManifestPath = " + _StrManifestPath + "; 错误信息:" + www.error);
                    }
                }
            }
        }
        /// <summary>
        /// 加载清单文件
        /// </summary>
        /// <returns></returns>
        public IEnumerator LoadManifetFile()
        {
            using (WWW www = new WWW(_manifestPath))
            {
                yield return(www);

                if (www.progress >= 1)
                {
                    //加载完成
                    _abReadManifest = www.assetBundle;
                    if (_abReadManifest == null)
                    {
                        Debug.Log("清单文件的AB包加载失败,请检查包路径");
                    }
                    else
                    {
                        //加载成功,读取清单文件
                        _manifest    = _abReadManifest.LoadAsset <AssetBundleManifest>(ConstsDefine.AB_MANIFEST);
                        IsLoadFinish = true;
                    }
                }
            }
        }
Esempio n. 16
0
    public void InitBundleDependencies()
    {
        bundles = new Dictionary <string, AssetBundle>();
        var uri = DataPath + "StreamingAssets";

        if (!File.Exists(uri))
        {
            return;
        }

        var stream      = File.ReadAllBytes(uri);
        var assetbundle = AssetBundle.LoadFromMemory(stream);

        manifest = assetbundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");

        bundleDependencies = new Dictionary <string, string[]>();
        foreach (var b in manifest.GetAllAssetBundles())
        {
            bundleDependencies[b] = manifest.GetAllDependencies(b);
        }

        assetbundle.Unload(false);
    }
Esempio n. 17
0
        /// <summary>
        /// 1. 检测循环依赖
        /// </summary>
        private void CheckCycleDepend(AssetBundleManifest unityManifest)
        {
            List <string> visited = new List <string>(100);
            List <string> stack   = new List <string>(100);

            string[] allAssetBundles = unityManifest.GetAllAssetBundles();
            for (int i = 0; i < allAssetBundles.Length; i++)
            {
                var element = allAssetBundles[i];
                visited.Clear();
                stack.Clear();

                // 深度优先搜索检测有向图有无环路算法
                if (CheckCycle(unityManifest, element, visited, stack))
                {
                    foreach (var ele in stack)
                    {
                        UnityEngine.Debug.LogWarning(ele);
                    }
                    throw new Exception($"Found cycle assetbundle : {element}");
                }
            }
        }
Esempio n. 18
0
 //AB包加载
 public T LoadAssetBundle <T>(string bag_name, string res_name)
     where T : Object
 {
     if (ab_manifest == null)
     {
         AssetBundle main_ab = AssetBundle.LoadFromFile(m_ab_path + "/" + main_ab_name);
         ab_manifest = main_ab.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
     }
     string[] dependent_name = ab_manifest.GetAllDependencies(res_name);
     for (int i = 0; i < dependent_name.Length; i++)
     {
         if (!m_ab_list.ContainsKey(dependent_name[i]))
         {
             m_ab_list.Add(dependent_name[i], AssetBundle.LoadFromFile(m_ab_path + "/" + dependent_name[i]));
         }
     }
     if (!m_ab_list.ContainsKey(bag_name))
     {
         m_ab_list.Add(bag_name, AssetBundle.LoadFromFile(m_ab_path + "/" + bag_name));
     }
     //根据包名资源名获取Obj
     return(GetObj <T>(bag_name, res_name));
 }
Esempio n. 19
0
    // Use this for initialization
    void Start()
    {
        var m = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "AB"));
        AssetBundleManifest am = m.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
        var dp = am.GetAllDependencies("prefabs");

        Debug.LogWarning("Test");
        foreach (var dd in dp)
        {
            Debug.LogWarning(dd);
        }
        var d      = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "sprite atlas"));
        var ab     = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "prefabs"));
        var prefab = ab.LoadAsset <GameObject>("UGUI Sprite Atlas");
        var image  = GameObject.Instantiate <GameObject>(prefab, transform);
        //image = GameObject.Instantiate<GameObject>(prefab, transform);
        //image.transform.localPosition = new Vector3(100f, 0f, 0f);
        //var s = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "res"));
        //var usa = s.LoadAsset<UISpriteAtlas>("Bn");
        //image.GetComponent<Image>().sprite = usa.GetSprite("UI_UP");
        //prefab = ab.LoadAsset<GameObject>("Image2");
        //GameObject.Instantiate(prefab, transform);
    }
Esempio n. 20
0
        /// <summary>
        /// 加载stream文件夹下的manifest文件
        /// </summary>
        /// <returns>The stream manifest.</returns>
        /// <param name="assetBundleName">Asset bundle name.</param>
        /// <param name="assetName">一般取值都是"AssetBundleManifest" </param>
        public void LoadStreamManifest()
        {
            if (this.stream_manifest != null)
            {
                return;
            }

            string platformName = Utility.GetPlatformName();
            string assetName    = "AssetBundleManifest";

            string      path   = Path.Combine(Utility.GetStreamingAssetsPath(), platformName + "/" + platformName);
            AssetBundle bundle = AssetBundle.LoadFromFile(path);

            if (bundle == null)
            {
                string error = "Failed to load stream manifest !";
                Debug.LogError(error);
                return;
            }

            this.stream_manifest = bundle.LoadAsset <AssetBundleManifest>(assetName);
            bundle.Unload(false);
        }
Esempio n. 21
0
        public IEnumerator Init()
        {
            resTab = mLuaManager.GetLuaTable("ResourceMsg");
            LuaTable _tab = resTab.GetInPath <LuaTable>("DemoUI");

            if (_tab != null)
            {
                Debug.Log(_tab["id"]);
            }
            yield return(1);

            if (!AppConst.DebugMode)
            {
                string      path           = Util.DataPath + "/StreamingAssets";
                AssetBundle manifestBundle = AssetBundle.LoadFromFile(path);
                manifest = (AssetBundleManifest)manifestBundle.LoadAsset("AssetBundleManifest");
                manifestBundle.Unload(false);
            }

            isReady = true;

            mLuaManager.CallFunction("Main.CreateUI");
        }
Esempio n. 22
0
    private AssetBundleManifest m_Manifest; //依赖文件配置

    /// <summary>
    /// 加载依赖文件配置
    /// </summary>
    private void LoadManifestBundle()
    {
        if (m_Manifest != null)
        {
            return;
        }

        string assetName = string.Empty;

#if UNITY_STANDALONE_WIN
        assetName = "Windows";
#elif UNITY_ANDROID
        assetName = "Android";
#elif UNITY_IPHONE
        assetName = "iOS";
#endif

        using (AssetBundleLoader loader = new AssetBundleLoader(assetName))
        {
            m_Manifest = loader.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
        }
        //AppDebug.Log("加载依赖文件配置 完毕");
    }
Esempio n. 23
0
        void InitForAssetBundle()
        {
            if (Application.isMobilePlatform == false && this.Simulate == false)
            {
                return;
            }

            _assetBundles.Clear();

            // Init manifest
            var manifestAssetBundle = this.LoadAssetBundle(ResConfig.MAINIFEST);

            if (manifestAssetBundle == null)
            {
                LogManager.Error("ResManager::InitForAssetBundle error, manifest bundle is null!");
                return;
            }
            _manifest = manifestAssetBundle.AssetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
            if (_manifest == null)
            {
                LogManager.Error("ResManager::InitForAssetBundle error, manifest is null!");
            }
        }
Esempio n. 24
0
    /// <summary>
    /// 获取总的AssetBundleManifest文件
    /// </summary>
    /// <param name="finish">完后加载后调用的委托</param>
    /// <returns></returns>
    public IEnumerator DownloadAssetBundleManifest(Action <AssetBundleManifest> finish = null)
    {
        WWW www = WWW.LoadFromCacheOrDownload(m_assetPath + PlatformManifest.GetMainManifest(Application.platform), version);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError(www.error);
        }
        else
        {
            AssetBundle bundle = www.assetBundle;                                                         //获取AssetBundle

            AssetBundleManifest manifest = bundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); //获取总的AssetBundleManifest
            bundle.Unload(false);
            Debug.Log(manifest);
            if (finish != null)
            {
                finish.Invoke(manifest);
            }
        }
    }
Esempio n. 25
0
        public void SetUpManifestSync()
        {
            string bundleName = "StreamingAssets";

            ResourceLoader manifestLoader = ResourceLoader.CreateNewResourceLoader <AssetBundleManifest> (bundleName, "AssetBundleManifest");

            AssetBundle manifestBundle = manifestLoader.LoadAssetsBundleFromFileSync();

            manifestLoader.LoadAssetsSync(manifestBundle);

//			Debug.Log (manifestLoader.assets.Length);

            for (int i = 0; i < manifestLoader.assets.Length; i++)
            {
                Debug.Log(manifestLoader.assets [i].name + "-------------");
            }

            manifest = manifestLoader.assets [0] as AssetBundleManifest;

            manifestReady = true;

            Destroy(manifestLoader.gameObject);
        }
Esempio n. 26
0
    /// <summary>
    /// 加载AssetBundleManifest
    /// </summary>
    /// <returns></returns>
    public IEnumerator LoadAssetBundleManifest()
    {
        //通过WWW对象来加载
        WWW www = new WWW(m_manifestPath);

        yield return(www);

        //错误判断
        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError("加载Manifest文件出错 : " + www.error);
        }
        else
        {
            if (www.progress >= 1.0f)
            {
                //加载完成,给类中的属性赋值
                m_assetbundle = www.assetBundle;
                m_manifest    = m_assetbundle.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
                m_Finish      = true;
            }
        }
    }
Esempio n. 27
0
        /// <summary>
        ///   打包AssetBundle
        /// </summary>
        public static void BuildAllAssetBundlesToTarget(BuildTarget target
                                                        , BuildAssetBundleOptions options)
        {
            string manifest_file             = EditorCommon.PATH + "/" + Common.MAIN_MANIFEST_FILE_NAME;
            AssetBundleManifest old_manifest = Common.LoadMainManifestByPath(manifest_file);

            if (!Directory.Exists(EditorCommon.PATH))
            {
                Directory.CreateDirectory(EditorCommon.PATH);
            }
            BuildPipeline.BuildAssetBundles(EditorCommon.PATH, options, target);
            AssetDatabase.Refresh();

            AssetBundleManifest new_manifest = Common.LoadMainManifestByPath(manifest_file);

            ComparisonAssetBundleManifest(old_manifest, new_manifest);
            ExportResourcesManifestFile(new_manifest);
            ResourcesManifest resoureces_manifest = Common.LoadResourcesManifestByPath(EditorCommon.RESOURCES_MANIFEST_FILE_PATH);

            CompressAssetBundles(resoureces_manifest, ref resoureces_manifest);
            resoureces_manifest.Save(EditorCommon.RESOURCES_MANIFEST_FILE_PATH);
            CopyNativeAssetBundleToStreamingAssets(resoureces_manifest);
        }
Esempio n. 28
0
        // Load AssetBundleManifest.
        public void Initialize(string manifestName, Action initOK)
        {
            if (Application.platform == RuntimePlatform.WindowsPlayer)
            {
                m_BaseDownloadingURL = "http://47.74.237.216/thumbgame/cdn/update/facebook/";
            }
            else
            {
                m_BaseDownloadingURL = Util.GetRelativePath();
            }

            LoadAsset <AssetBundleManifest>(manifestName, new string[] { "AssetBundleManifest" }, delegate(UObject[] objs) {
                if (objs.Length > 0)
                {
                    m_AssetBundleManifest = objs[0] as AssetBundleManifest;
                    m_AllManifest         = m_AssetBundleManifest.GetAllAssetBundles();
                }
                if (initOK != null)
                {
                    initOK();
                }
            });
        }
Esempio n. 29
0
    protected override void InitManager()
    {
//#if UNITY_ANDROID
//        m_baseDownloadingURL = string.Format("{0}/{1}/", Application.streamingAssetsPath, ResourceUtil.GetPlatformName());
//        m_baseDownloadingURL = AssetBundles.AssetManager.BaseDownloadingURL;

//#else
//        m_baseDownloadingURL = string.Format("File:///{0}/{1}/", Application.streamingAssetsPath, ResourceUtil.GetPlatformName());
//#endif

        m_baseDownloadingURL = AssetBundles.AssetManager.BaseDownloadingURL;
        m_baseLocalStorage   = string.Format("{0}/{1}/", Application.streamingAssetsPath, ResourceUtil.GetPlatformName());
        //m_baseDownloadingURL = ResourcePath.GetBaseURL();

        m_assetBundleManifest = AssetManager.AssetBundleManifestObject;
        //UnloadAssetBundle(ResourceUtil.GetPlatformName());

        //string manifestPath = string.Format("{0}/{1}/{1}", Application.streamingAssetsPath, ResourceUtil.GetPlatformName());

        //AssetBundle bundle = AssetBundle.LoadFromFile(manifestPath);
        //m_assetBundleManifest = (AssetBundleManifest)bundle.LoadAsset("AssetBundleManifest", typeof(AssetBundleManifest));
        //bundle.Unload(false);
    }
Esempio n. 30
0
    private void LoadStreamResXml(string url)
    {
        //var ct = StartCoroutine(LoadXml(url));

        Action <AssetBundle> callback = (bundle) =>
        {
            manifest = bundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");

            //获取到的name是 xxx.ab 这种带后缀的bundle文件名
            //string[] resNames = manifest.GetAllAssetBundles();
            //for (int i = 0; i < resNames.Length; i++)
            //{
            //    Debug.Log("i:" + i + " name:" + resNames[i]);
            //}
        };

        Action <string> errorBack = (errorInfo) =>
        {
            LogMgr.E("SimpleResMgr", "LoadXml", "errorInfo:" + errorInfo, BeShowLog);
        };

        StartCoroutine(LoadStreamBundle(url, callback, errorBack));
    }
Esempio n. 31
0
        /// <summary>
        /// 初始化
        /// </summary>
        public void Initialize(string assetpath)
        {
            AssetPath = assetpath;
            byte[] stream = null;
            string uri = AssetPath + AppConst.AssetDirname;
            bundles = new Dictionary<string, AssetBundle>();
            if (!File.Exists(uri)) return;
            #if UNITY_STANDALONE
            stream = File.ReadAllBytes(uri);
            assetbundle = AssetBundle.CreateFromMemoryImmediate(stream);
            manifest = assetbundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
            Debug.Log("AssetBundleManifest is Loaded");
            #else

            #endif
        }
 /// <summary>
 /// 销毁资源
 /// </summary>
 void OnDestroy()
 {
     if (shared != null) shared.Unload(true);
     if (manifest != null) manifest = null;
     Debug.Log("~ResourceManager was destroy!");
 }
 /// <summary>
 /// 初始化
 /// </summary>
 void Initialize()
 {
     byte[] stream = null;
     string uri = string.Empty;
     bundles = new Dictionary<string, AssetBundle>();
     uri = Util.DataPath + AppConst.AssetDirname;
     if (!File.Exists(uri)) return;
     stream = File.ReadAllBytes(uri);
     assetbundle = AssetBundle.CreateFromMemoryImmediate(stream);
     manifest = assetbundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
 }