private void OnGUI()
        {
            if (AssetBundles.mainManifest == null)
            {
                GUILayout.Label("no loaded AssetBundleManifest");
                return;
            }

            if (GUILayout.Button("UnloadUnused"))
            {
                AssetBundles.UnloadUnused(true);
            }

            using (new GUILayout.HorizontalScope())
            {
                using (var sv = new GUILayout.ScrollViewScope(scrollPos, "box", GUILayout.MaxWidth(Screen.width * 0.4f)))
                {
                    scrollPos = sv.scrollPosition;
                    foreach (var abInfo in AssetBundles.mainManifest.AssetBundleInfos.OrderBy(o => o.Name))
                    {
                        DrawAssetBundle(abInfo);
                    }
                }

                using (var sv = new GUILayout.ScrollViewScope(scrollPos2, "box", GUILayout.MaxWidth(Screen.width * 0.6f)))
                {
                    scrollPos2 = sv.scrollPosition;

                    DrawDetails(selectedAssetBundleInfo);
                }
            }
        }
 /// <summary>
 /// 异步加载AB包(提供进度回调)
 /// </summary>
 /// <param name="assetBundleName">AB包名称</param>
 /// <param name="loadingAction">加载中事件</param>
 /// <param name="isManifest">是否是加载清单</param>
 /// <returns>协程迭代器</returns>
 private IEnumerator LoadAssetBundleAsync(string assetBundleName, HTFAction <float> loadingAction, bool isManifest = false)
 {
     if (!AssetBundles.ContainsKey(assetBundleName))
     {
         using (UnityWebRequest request = isManifest
             ? UnityWebRequestAssetBundle.GetAssetBundle(AssetBundleRootPath + assetBundleName)
             : UnityWebRequestAssetBundle.GetAssetBundle(AssetBundleRootPath + assetBundleName, GetAssetBundleHash(assetBundleName)))
         {
             request.SendWebRequest();
             while (!request.isDone)
             {
                 loadingAction?.Invoke(request.downloadProgress);
                 yield return(null);
             }
             if (!request.isNetworkError && !request.isHttpError)
             {
                 AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);
                 if (bundle)
                 {
                     AssetBundles.Add(assetBundleName, bundle);
                 }
                 else
                 {
                     throw new HTFrameworkException(HTFrameworkModule.Resource, "请求:" + request.url + " 未下载到AB包!");
                 }
             }
             else
             {
                 throw new HTFrameworkException(HTFrameworkModule.Resource, "请求:" + request.url + " 遇到网络错误:" + request.error + "!");
             }
         }
     }
     yield return(null);
 }
        // Update is called once per frame
        void Update()
        {
            formatValues["AppVersion"] = AssetBundles.AppVersion;
            if (AssetBundles.Version != null)
            {
                formatValues["BundleVersion"] = AssetBundles.Version.bundleVersion;
            }


            if (AssetBundles.Status == AssetBundleStatus.Downloading)
            {
                progress = AssetBundles.DownloadProgress / (float)AssetBundles.DownloadTotal;
                if (AssetBundles.DownloadItemTotalBytes > 0)
                {
                    progress += (1f / AssetBundles.DownloadTotal) * (AssetBundles.DownloadItemReceiveBytes / (float)AssetBundles.DownloadItemTotalBytes);
                }
                formatValues["DownloadTotal"]    = AssetBundles.DownloadTotal;
                formatValues["DownloadProgress"] = AssetBundles.DownloadProgress;
                string spdUnit;
                formatValues["DownloadSpeed"] = string.Format("{0:0.#}{1}/s", AssetBundles.GetBytesUnit(AssetBundles.DownloadSpeed, out spdUnit), spdUnit);
            }
            else if (AssetBundles.Status == AssetBundleStatus.Preloading)
            {
                progress = AssetBundles.PreloadedProgress / (float)AssetBundles.PreloadedTotal;
                formatValues["PreloadTotal"]    = AssetBundles.PreloadedTotal;
                formatValues["PreloadProgress"] = AssetBundles.PreloadedProgress;
            }
        }
Exemplo n.º 4
0
        protected override void Init()
        {
            base.Init();

            m_Settings.Init();

            if (ILRuntimeIniter.HasLoadAnyAssembly)
            {
                ILRuntimeLoaded();
            }
            else
            {
                TextAsset dll, pdb = default;
                if (hotFixAsset != default)
                {
                    dll = hotFixAsset;
                }
                else
                {
                    AssetBundles abs = ShipDockApp.Instance.ABs;
                    dll = abs.Get <TextAsset>(m_Settings.HotFixABName, m_Settings.HotFixDLL);
                    pdb = abs.Get <TextAsset>(m_Settings.HotFixABName, m_Settings.HotFixPDB);
                }

                StartHotFixeByAsset(this, dll, pdb);
            }
        }
Exemplo n.º 5
0
        public void Start(int ticks)
        {
            Tester.Instance.Log(TesterBaseApp.LOG, IsStarted, "warning: ShipDockApplication has started");

            if (IsStarted)
            {
                return;
            }

            Notificater   = new Notifications <int>();
            ABs           = new AssetBundles();
            Servers       = new Servers(OnServersInit);
            Datas         = new DataWarehouse();
            AssetsPooling = new AssetsPooling();
            StateMachines = new StateMachines
            {
                FSMFrameUpdater   = OnFSMFrameUpdater,
                StateFrameUpdater = OnStateFrameUpdater
            };
            mFSMUpdaters   = new KeyValueList <IStateMachine, IUpdate>();
            mStateUpdaters = new KeyValueList <IState, IUpdate>();

            if (ticks > 0)
            {
                TicksUpdater = new TicksUpdater(ticks);
            }

            ShipDockConsts.NOTICE_APPLICATION_STARTUP.Broadcast();

            IsStarted = true;
            mAppStarted?.Invoke();
            mAppStarted = null;
        }
Exemplo n.º 6
0
        private void OnStartBattle(INoticeBase <int> obj)
        {
            Consts.D_BATTLE.GetData <BattleData>().StartBattle();

            AssetBundles abs = ShipDockApp.Instance.ABs;
            GameObject   map = abs.GetAndQuote <GameObject>("is_king_map/mission_1", "Map", out AssetQuoteder quoteder);

            Consts.UIM_BATTLE.LoadAndOpenUI <UIBattleModular>(default, Consts.AB_UI_BATTLE);
        public Task <UnityEngine.Object> LoadAssetAsync(string assetName, Type assetType, object lifetime = null)
        {
            if (assetNamePrefix != null)
            {
                assetName = assetNamePrefix + assetName;
            }

            return(AssetBundles.LoadAssetAsync(assetName, assetType, lifetime));
        }
Exemplo n.º 8
0
    /// <summary>
    /// 加载UI资源并打开热更界面
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="stackName">界面名</param>
    /// <param name="onUIOpen">打开热更界面后的回调函数</param>
    /// <param name="UIABNames">需要加载的资源列表</param>
    public static void LoadAndOpenHotFixUI <T>(this string stackName, Action <T> onUIOpen, params string[] UIABNames) where T : UIModularHotFixer, new()
    {
        int max = UIABNames.Length;

        if (max > 0)
        {
            Framework    framework = Framework.Instance;
            UIManager    uis       = framework.GetUnit <UIManager>(Framework.UNIT_UI);
            AssetBundles abs       = framework.GetUnit <AssetBundles>(Framework.UNIT_AB);
            if (abs != default)
            {
                AssetsLoader loader = new AssetsLoader();
                loader.CompleteEvent.AddListener((suc, ld) =>
                {
                    if (suc)
                    {
                        ld?.Dispose();
                        uis.OnLoadingAlert?.Invoke(false);

                        T result = OpenHotFixUI <T>(stackName);
                        onUIOpen?.Invoke(result);
                    }
                    else
                    {
                    }
                });
                string abName;
                for (int i = 0; i < max; i++)
                {
                    abName = UIABNames[i];
                    if (!abs.HasBundel(abName))
                    {
                        loader.Add(abName, true, true);
                    }
                    else
                    {
                    }
                }
                if (loader.ResList.Count > 0)
                {
                    uis.OnLoadingAlert?.Invoke(true);
                }
                else
                {
                }
                loader.Load(out _);
            }
            else
            {
            }
        }
        else
        {
            T result = OpenHotFixUI <T>(stackName);
            onUIOpen?.Invoke(result);
        }
    }
Exemplo n.º 9
0
    private void OnCreateBoard(UIElimModular ui)
    {
        AssetBundles abs   = ShipDockApp.Instance.ABs;
        GameObject   board = abs.GetAndQuote <GameObject>("elim_game_res/prefabs", "EliminatePlay", out _);
        GameObject   map   = abs.GetAndQuote <GameObject>("elim_game_map", "MissionMap", out _);

        EliminatePlayComponent comp = board.GetComponent <EliminatePlayComponent>();

        comp.StartEliminatePlay();
    }
Exemplo n.º 10
0
        protected virtual void AddGridAssetToPool(ref AssetBundles abs, ref string abName, ref string assetName, int index)
        {
            Sprite gridSprite = abs.Get <Sprite>(abName, assetName);

#if LOG_GRID_SHAPE_RES_NULL
            "error:gridSprite is null. ab name is {0}, res name is {1}".Log(gridSprite == default, abName, abName);
            "log:Add grid asset to pool abName is {0}, asset name is {1}, index is {2}".Log(abName, assetName, index.ToString());
#endif
            GridSpriteList[index] = gridSprite;
        }
Exemplo n.º 11
0
    /// <summary>
    /// 卸载资源
    /// </summary>
    public void Unload(bool unloadMainAsset = false)
    {
        // 资源不允许被卸载
        if (IsDontUnload)
        {
            return;
        }

        // 如果资源没有载入不处理
        if (mState != STATE.LOADED)
        {
            return;
        }

        // 指明卸载主资源
        if (unloadMainAsset)
        {
            MainAsset = null;
        }

        // 如果主资源为空,设置为卸载状态
        if (MainAsset == null)
        {
            mState = STATE.UNLOAD;
        }

        // 删除AssetBundle资源引用
        foreach (string ab in AssetBundles)
        {
            // 如果AB2ResourceMap中不需要处理
            if (!ResourceMgr.Instance.AB2ResourceMap.ContainsKey(ab))
            {
                continue;
            }

            // 删除资源引用关系
            ResourceMgr.Instance.AB2ResourceMap[ab].Remove(this);

            // 如果AssetBundle已经不存在引用了,直接卸载AssetBundle
            // 否则不能卸载ab资源
            if (ResourceMgr.Instance.AB2ResourceMap[ab].Count != 0)
            {
                continue;
            }

            // 删除引用关系
            ResourceMgr.Instance.AB2ResourceMap.Remove(ab);

            // 卸载资源
            ResourceMgr.Instance.AssetBundleMap[ab].Unload(false);
        }

        // 清空AssetBundles
        AssetBundles.Clear();
    }
 /// <summary>
 /// 通过名称获取指定的AssetBundle
 /// </summary>
 /// <param name="assetBundleName">名称</param>
 /// <returns>AssetBundle</returns>
 public AssetBundle GetAssetBundle(string assetBundleName)
 {
     if (AssetBundles.ContainsKey(assetBundleName))
     {
         return(AssetBundles[assetBundleName]);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 13
0
    // Start is called before the first frame update
    IEnumerator Start()
    {
        yield return(AssetBundles.InitializeAsync());

        var task = AssetBundles.InstantiateAsync("Assets/Example/Src/Cube");

        yield return(task);

        task.Result.transform.position = Random.insideUnitSphere;

        AssetBundles.InstantiateAsync("Assets/Example/Src/Sphere");
    }
Exemplo n.º 14
0
        private void OnPreloadComplete(bool successed, Loader target)
        {
            AssetBundles ABs    = ShipDockApp.Instance.ABs;
            GameObject   prefab = ABs.Get(FWConsts.ASSET_RES_BRIGEDS, "BananaRoleRes");
            GameObject   role;
            int          max = 10;

            for (int i = 0; i < max; i++)
            {
                role = Instantiate(prefab);
            }

            UIManager uis = ShipDockApp.Instance.UIs;

            uis.Open <RoleChooser>(FWConsts.UI_NAME_ROLE_CHOOSER);
        }
 /// <summary>
 /// 卸载所有资源(卸载AssetBundle)
 /// </summary>
 /// <param name="unloadAllLoadedObjects">是否同时卸载所有实体对象</param>
 public void UnLoadAllAsset(bool unloadAllLoadedObjects = false)
 {
     if (LoadMode == ResourceLoadMode.Resource)
     {
         Resources.UnloadUnusedAssets();
     }
     else
     {
         foreach (var assetBundle in AssetBundles)
         {
             assetBundle.Value.Unload(unloadAllLoadedObjects);
         }
         AssetBundles.Clear();
         AssetBundleHashs.Clear();
         AssetBundle.UnloadAllAssetBundles(unloadAllLoadedObjects);
     }
 }
        /// <summary>
        /// 异步加载依赖AB包
        /// </summary>
        /// <param name="assetBundleName">AB包名称</param>
        /// <returns>协程迭代器</returns>
        private IEnumerator LoadDependenciesAssetBundleAsync(string assetBundleName)
        {
            if (LoadMode == ResourceLoadMode.AssetBundle)
            {
#if UNITY_EDITOR
                if (!IsEditorMode)
                {
                    yield return(LoadAssetBundleManifestAsync());

                    if (AssetBundleManifest != null)
                    {
                        string[] dependencies = AssetBundleManifest.GetAllDependencies(assetBundleName);
                        foreach (string item in dependencies)
                        {
                            if (AssetBundles.ContainsKey(item))
                            {
                                continue;
                            }

                            yield return(LoadAssetBundleAsync(item));
                        }
                    }
                }
#else
                yield return(LoadAssetBundleManifestAsync());

                if (AssetBundleManifest != null)
                {
                    string[] dependencies = AssetBundleManifest.GetAllDependencies(assetBundleName);
                    foreach (string item in dependencies)
                    {
                        if (AssetBundles.ContainsKey(item))
                        {
                            continue;
                        }

                        yield return(LoadAssetBundleAsync(item));
                    }
                }
#endif
            }
            yield return(null);
        }
 /// <summary>
 /// 卸载资源(卸载AssetBundle)
 /// </summary>
 /// <param name="assetBundleName">AB包名称</param>
 /// <param name="unloadAllLoadedObjects">是否同时卸载所有实体对象</param>
 public void UnLoadAsset(string assetBundleName, bool unloadAllLoadedObjects = false)
 {
     if (LoadMode == ResourceLoadMode.Resource)
     {
         Resources.UnloadUnusedAssets();
     }
     else
     {
         if (AssetBundles.ContainsKey(assetBundleName))
         {
             AssetBundles[assetBundleName].Unload(unloadAllLoadedObjects);
             AssetBundles.Remove(assetBundleName);
         }
         if (AssetBundleHashs.ContainsKey(assetBundleName))
         {
             AssetBundleHashs.Remove(assetBundleName);
         }
     }
 }
Exemplo n.º 18
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            var assetPath = AssetDatabase.GetAssetPath(target);
            var importer  = AssetImporter.GetAtPath(assetPath);

            if (!importer)
            {
                return;
            }
            float margin = 2;

            r.xMin += margin;
            r.xMax -= margin;
            r.yMin += margin;

            r.height = EditorGUIUtility.singleLineHeight;
            float labelWidth = 80;
            float labelSpace = 0;
            Rect  rect;

            rect = GUIDrawLabel(new Rect(r.x, r.y, labelWidth, r.height), new GUIContent("Asset Path: "));
            string value;

            value = assetPath;
            GUIDrawValue(new Rect(rect.xMax + labelSpace, r.y, r.width - rect.width - labelSpace, r.height), new GUIContent(value, value));

            value = BuildAssetBundles.GetAddressableName(assetPath);
            r.y  += EditorGUIUtility.singleLineHeight;
            rect  = GUIDrawLabel(new Rect(r.x, r.y, labelWidth, r.height), new GUIContent("Asset Name: "));
            GUIDrawValue(new Rect(rect.xMax + labelSpace, r.y, r.width - rect.width - labelSpace, r.height), new GUIContent(value, value));

            value = target.GetType().Name;
            r.y  += EditorGUIUtility.singleLineHeight;
            rect  = GUIDrawLabel(new Rect(r.x, r.y, labelWidth, r.height), new GUIContent("Asset Type: "));
            GUIDrawValue(new Rect(rect.xMax + labelSpace, r.y, r.width - rect.width - labelSpace, r.height), new GUIContent(value, value));

            string bundleName = AssetDatabase.GetImplicitAssetBundleName(assetPath);

            value = AssetBundles.IsPreloadedBundle(bundleName).ToString();
            r.y  += EditorGUIUtility.singleLineHeight;
            rect  = GUIDrawLabel(new Rect(r.x, r.y, labelWidth, r.height), new GUIContent("Preloaded: "));
            GUIDrawValue(new Rect(rect.xMax + labelSpace, r.y, r.width - rect.width - labelSpace, r.height), new GUIContent(value, value));
        }
        /// <summary>
        /// 异步加载AB包清单
        /// </summary>
        /// <returns>协程迭代器</returns>
        private IEnumerator LoadAssetBundleManifestAsync()
        {
            if (string.IsNullOrEmpty(AssetBundleManifestName))
            {
                throw new HTFrameworkException(HTFrameworkModule.Resource, "请设置资源管理模块的 Manifest Name 属性,为所有AB包提供依赖清单!");
            }
            else
            {
                if (AssetBundleManifest == null)
                {
                    yield return(LoadAssetBundleAsync(AssetBundleManifestName, true));

                    if (AssetBundles.ContainsKey(AssetBundleManifestName))
                    {
                        AssetBundleManifest = AssetBundles[AssetBundleManifestName].LoadAsset <AssetBundleManifest>("AssetBundleManifest");
                        UnLoadAsset(AssetBundleManifestName);
                    }
                }
            }
            yield return(null);
        }
Exemplo n.º 20
0
 /// <summary>
 /// AssetBundle资源路径
 /// </summary>
 /// <param name="bundle"></param>
 /// <param name="path"></param>
 /// <returns></returns>
 public static string GetAssetPath(AssetBundles bundle, string path)
 {
     path = string.Format("{0}/{1}", bundle, path);
     return(GetAssetPath(path));
 }
Exemplo n.º 21
0
        private void InitGridTypeLibs(string girdWeights)
        {
            GridTypes gridTypes = mCore.GridTypes;

            gridTypes.NormalGridType = m_NormalGridType;

            TDData td = DataParser.ParseParamToTD(ref girdWeights);

            int weightCount = td.Source.Count;
            KeyValueList <int, int> weightMapper = new KeyValueList <int, int>();

            for (int i = 0; i < weightCount; i++)
            {
                int gridType = td.GetIntValue(i, 0);
                int weight   = td.GetIntValue(i, 1);
                weightMapper[gridType] = weight;//定义权重
            }

            GridTypeItem value;
            int          max = m_GridTypeItems.Count, key;

            for (int i = 0; i < max; i++)
            {
                value = m_GridTypeItems[i];
                key   = value.id;
                string abName    = value.prefabABName;
                string assetName = value.prefabResName;
                GameObject creater()
                {
                    AssetBundles abs    = Framework.Instance.GetUnit <AssetBundles>(Framework.UNIT_AB);
                    GameObject   result = abs.Get <GameObject>(abName, assetName);

                    result = Instantiate(result);
                    return(result);
                };

                if (weightCount > 0)
                {
                    int weight = 1;
                    if (key == gridTypes.NormalGridType)
                    {
                        weight = weightCount > 0 ? 0 : 1;//如果包含消除格类型的权重配置则不使用自动的普通消除格类型值
                        gridTypes.SetGridCreater(key, value.isSpriteAsset, creater, weight);
                        "log:Grid type is {0}, ab name is {1}, res name is {2}, asset static is ({3})".Log(key.ToString(), abName, assetName, value.isSpriteAsset.ToString());

                        int m = weightCount;
                        for (int n = 0; n < m; n++)
                        {
                            key    = weightMapper.Keys[n];
                            weight = weightMapper[key];
                            gridTypes.SetGridCreater(key, value.isSpriteAsset, creater, weight, gridTypes.NormalGridType);//根据权重配置向全局类型库添加普通消除格类型
                            "log:Grid type is {0}, ab name is {1}, res name is {2}, asset static is ({3})".Log(key.ToString(), abName, assetName, value.isSpriteAsset.ToString());
                        }
                    }
                    else
                    {
                        gridTypes.SetGridCreater(key, value.isSpriteAsset, creater, 0);
                    }
                }
                else
                {
                    int weight = value.isInvalidRandom ? 0 : 1;
                    gridTypes.SetGridCreater(key, value.isSpriteAsset, creater, weight);
                    //gridTypes.AddInvalidWeightGrid(0);
                    //gridTypes.AddInvalidWeightGrid(2);
                    "log:Grid type is {0}, ab name is {1}, res name is {2}, asset static is ({3})".Log(key.ToString(), abName, assetName, value.isSpriteAsset.ToString());
                }
            }
        }
        /// <summary>
        /// 加载资源(异步)
        /// </summary>
        /// <typeparam name="T">资源类型</typeparam>
        /// <param name="info">资源信息标记</param>
        /// <param name="loadingAction">加载中事件</param>
        /// <param name="loadDoneAction">加载完成事件</param>
        /// <param name="isPrefab">是否是加载预制体</param>
        /// <param name="parent">预制体加载完成后的父级</param>
        /// <param name="isUI">是否是加载UI</param>
        /// <returns>加载协程迭代器</returns>
        public IEnumerator LoadAssetAsync <T>(ResourceInfoBase info, HTFAction <float> loadingAction, HTFAction <T> loadDoneAction, bool isPrefab, Transform parent, bool isUI) where T : UnityEngine.Object
        {
            float beginTime = Time.realtimeSinceStartup;

            //单线加载,如果其他地方在加载资源,则等待
            if (_isLoading)
            {
                yield return(_loadWait);
            }

            //轮到本线路加载资源
            _isLoading = true;

            //等待相关依赖资源的加载
            yield return(LoadDependenciesAssetBundleAsync(info.AssetBundleName));

            float waitTime = Time.realtimeSinceStartup;

            UnityEngine.Object asset = null;

            if (LoadMode == ResourceLoadMode.Resource)
            {
                ResourceRequest request = Resources.LoadAsync <T>(info.ResourcePath);
                while (!request.isDone)
                {
                    loadingAction?.Invoke(request.progress);
                    yield return(null);
                }
                asset = request.asset;
                if (asset)
                {
                    if (isPrefab)
                    {
                        asset = ClonePrefab(asset as GameObject, parent, isUI);
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Resource, "加载资源失败:Resources文件夹中不存在资源 " + info.ResourcePath + "!");
                }
            }
            else
            {
#if UNITY_EDITOR
                if (IsEditorMode)
                {
                    loadingAction?.Invoke(1);
                    yield return(null);

                    asset = AssetDatabase.LoadAssetAtPath <T>(info.AssetPath);
                    if (asset)
                    {
                        if (isPrefab)
                        {
                            asset = ClonePrefab(asset as GameObject, parent, isUI);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Resource, "加载资源失败:路径中不存在资源 " + info.AssetPath + "!");
                    }
                }
                else
                {
                    yield return(LoadAssetBundleAsync(info.AssetBundleName, loadingAction));

                    if (AssetBundles.ContainsKey(info.AssetBundleName))
                    {
                        asset = AssetBundles[info.AssetBundleName].LoadAsset <T>(info.AssetPath);
                        if (asset)
                        {
                            if (isPrefab)
                            {
                                asset = ClonePrefab(asset as GameObject, parent, isUI);
                            }
                        }
                        else
                        {
                            throw new HTFrameworkException(HTFrameworkModule.Resource, "加载资源失败:AB包 " + info.AssetBundleName + " 中不存在资源 " + info.AssetPath + " !");
                        }
                    }
                }
#else
                yield return(LoadAssetBundleAsync(info.AssetBundleName, loadingAction));

                if (AssetBundles.ContainsKey(info.AssetBundleName))
                {
                    asset = AssetBundles[info.AssetBundleName].LoadAsset <T>(info.AssetPath);
                    if (asset)
                    {
                        if (isPrefab)
                        {
                            asset = ClonePrefab(asset as GameObject, parent, isUI);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Resource, "加载资源失败:AB包 " + info.AssetBundleName + " 中不存在资源 " + info.AssetPath + " !");
                    }
                }
#endif
            }

            float endTime = Time.realtimeSinceStartup;

            //Log.Info(string.Format("异步加载资源{0}[{1}模式]:\r\n{2}\r\n等待耗时:{3}秒  加载耗时:{4}秒"
            //    , asset ? "成功" : "失败"
            //    , LoadMode.ToString()
            //    , LoadMode == ResourceLoadMode.Resource ? info.GetResourceFullPath() : info.GetAssetBundleFullPath(AssetBundleRootPath)
            //    , waitTime - beginTime
            //    , endTime - waitTime));

            if (asset)
            {
                DataSetInfo dataSet = info as DataSetInfo;
                if (dataSet != null && dataSet.Data != null)
                {
                    asset.Cast <DataSetBase>().Fill(dataSet.Data);
                }

                loadDoneAction?.Invoke(asset as T);
            }
            else
            {
                loadDoneAction?.Invoke(null);
            }
            asset = null;

            //本线路加载资源结束
            _isLoading = false;
        }
        void DrawDetails(AssetBundles.AssetBundleInfo abInfo)
        {
            if (abInfo == null)
            {
                return;
            }
            bool   isLoaded  = IsAssetBundleLoaded(abInfo.Name);
            string loadError = null;

            AssetBundles.AssetBundleRef abRef;
            if (AssetBundles.abRefs.TryGetValue(abInfo.Key, out abRef))
            {
                if (abRef.AssetBundle)
                {
                }
                else
                {
                    if (abRef.Error != null)
                    {
                        loadError = abRef.Error.Message;
                    }
                }
            }

            GUILayout.Label(abInfo.Name);
            GUILayout.Space(5);
            if (loadError != null)
            {
                GUI.color = Color.red;
                GUILayout.Label(loadError);
                GUI.color = Color.white;
            }

            var deps = manifest.GetDirectDependencies(abInfo.Name);

            if (GUILayout.Button(string.Format("Dependency ({0})", deps.Length), "label"))
            {
                isDependencyExpanded = !isDependencyExpanded;
            }

            if (isDependencyExpanded)
            {
                foreach (var dep in deps)
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Space(16);
                        GUILayout.Label(dep);
                    }
                }
            }
            GUILayout.Space(5);


            var depSelf = (from abName in AssetBundles.AllAssetBundleNames()
                           where manifest.GetDirectDependencies(abName).Contains(abInfo.Name)
                           select abName).ToArray();

            if (GUILayout.Button(string.Format("Dependency Self ({0})", depSelf.Length), "label"))
            {
                isDependencySelfExpanded = !isDependencySelfExpanded;
            }

            if (isDependencySelfExpanded)
            {
                foreach (var abName in depSelf)
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Space(16);
                        GUILayout.Label(abName);
                    }
                }
            }
            GUILayout.Space(5);

            List <AssetBundles.AssetBundleRef> ownerDeps = new List <AssetBundles.AssetBundleRef>();

            if (abRef != null)
            {
                foreach (var item in AssetBundles.abRefs.Values)
                {
                    if (item == abRef)
                    {
                        continue;
                    }
                    if (!item.IsDependent)
                    {
                        continue;
                    }
                    if (item.AssetBundleInfo.Dependencies != null)
                    {
                        foreach (var dep in item.AssetBundleInfo.Dependencies)
                        {
                            if (dep == abRef.AssetBundleInfo)
                            {
                                ownerDeps.Add(item);
                            }
                        }
                    }
                }
            }

            using (new GUILayout.HorizontalScope())
            {
                if (GUILayout.Button(string.Format("Lifetime Dependency ({0})", ownerDeps.Count), "label"))
                {
                    isOwnerDependencyExpanded = !isOwnerDependencyExpanded;
                }
            }

            if (isOwnerDependencyExpanded)
            {
                foreach (var item in ownerDeps)
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Space(16);
                        GUILayout.Label(item.AssetBundleInfo.Name);
                    }
                }
            }

            List <object> lifetimeObjects = new List <object>();

            if (isLoaded && abRef != null)
            {
                foreach (WeakReference weakRef in abRef.Owners)
                {
                    object obj = weakRef.Target;
                    if (obj != null)
                    {
                        lifetimeObjects.Add(obj);
                    }
                }
            }

            using (new GUILayout.HorizontalScope())
            {
                if (GUILayout.Button(string.Format("Lifetime ({0})", lifetimeObjects.Count), "label"))
                {
                    isOwnerObjectExpanded = !isOwnerObjectExpanded;
                }
            }
            if (isOwnerObjectExpanded)
            {
                if (isLoaded && abRef != null)
                {
                    foreach (var obj in lifetimeObjects)
                    {
                        if (obj != null)
                        {
                            using (new GUILayout.HorizontalScope())
                            {
                                GUILayout.Space(16);
                                if (GUILayout.Button(string.Format("{0} ({1})", (obj.ToString() ?? string.Empty), obj.GetType().FullName), "label"))
                                {
                                    if (obj is UnityEngine.Object)
                                    {
                                        Object o = obj as UnityEngine.Object;
                                        EditorGUIUtility.PingObject(o);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// 加载资源(异步)
        /// </summary>
        /// <typeparam name="T">资源类型</typeparam>
        /// <param name="info">资源信息标记</param>
        /// <param name="loadingAction">加载中事件</param>
        /// <param name="loadDoneAction">加载完成事件</param>
        /// <param name="isPrefab">是否是加载预制体</param>
        /// <param name="parent">预制体加载完成后的父级</param>
        /// <param name="isUI">是否是加载UI</param>
        /// <returns>加载协程迭代器</returns>
        public IEnumerator LoadAssetAsync <T>(ResourceInfoBase info, HTFAction <float> loadingAction, HTFAction <T> loadDoneAction, bool isPrefab, Transform parent, bool isUI) where T : UnityEngine.Object
        {
            DateTime beginTime = DateTime.Now;

            if (_isLoading)
            {
                yield return(_loadWait);
            }

            _isLoading = true;

            yield return(Main.Current.StartCoroutine(LoadDependenciesAssetBundleAsync(info.AssetBundleName)));

            DateTime waitTime = DateTime.Now;

            UnityEngine.Object asset = null;

            if (LoadMode == ResourceLoadMode.Resource)
            {
                ResourceRequest request = Resources.LoadAsync <T>(info.ResourcePath);
                while (!request.isDone)
                {
                    loadingAction?.Invoke(request.progress);
                    yield return(null);
                }
                asset = request.asset;
                if (asset)
                {
                    if (isPrefab)
                    {
                        asset = ClonePrefab(asset as GameObject, parent, isUI);
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Resource, "加载资源失败:Resources文件夹中不存在资源 " + info.ResourcePath + "!");
                }
            }
            else
            {
#if UNITY_EDITOR
                if (IsEditorMode)
                {
                    loadingAction?.Invoke(1);
                    yield return(null);

                    asset = AssetDatabase.LoadAssetAtPath <T>(info.AssetPath);
                    if (asset)
                    {
                        if (isPrefab)
                        {
                            asset = ClonePrefab(asset as GameObject, parent, isUI);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Resource, "加载资源失败:路径中不存在资源 " + info.AssetPath + "!");
                    }
                }
                else
                {
                    if (AssetBundles.ContainsKey(info.AssetBundleName))
                    {
                        loadingAction?.Invoke(1);
                        yield return(null);

                        asset = AssetBundles[info.AssetBundleName].LoadAsset <T>(info.AssetPath);
                        if (asset)
                        {
                            if (isPrefab)
                            {
                                asset = ClonePrefab(asset as GameObject, parent, isUI);
                            }
                        }
                        else
                        {
                            throw new HTFrameworkException(HTFrameworkModule.Resource, "加载资源失败:AB包 " + info.AssetBundleName + " 中不存在资源 " + info.AssetPath + " !");
                        }
                    }
                    else
                    {
                        using (UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(AssetBundleRootPath + info.AssetBundleName, GetAssetBundleHash(info.AssetBundleName)))
                        {
                            request.SendWebRequest();
                            while (!request.isDone)
                            {
                                loadingAction?.Invoke(request.downloadProgress);
                                yield return(null);
                            }
                            if (!request.isNetworkError && !request.isHttpError)
                            {
                                AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);
                                if (bundle)
                                {
                                    asset = bundle.LoadAsset <T>(info.AssetPath);
                                    if (asset)
                                    {
                                        if (isPrefab)
                                        {
                                            asset = ClonePrefab(asset as GameObject, parent, isUI);
                                        }
                                    }
                                    else
                                    {
                                        throw new HTFrameworkException(HTFrameworkModule.Resource, "加载资源失败:AB包 " + info.AssetBundleName + " 中不存在资源 " + info.AssetPath + " !");
                                    }

                                    if (IsCacheAssetBundle)
                                    {
                                        if (!AssetBundles.ContainsKey(info.AssetBundleName))
                                        {
                                            AssetBundles.Add(info.AssetBundleName, bundle);
                                        }
                                    }
                                    else
                                    {
                                        bundle.Unload(false);
                                    }
                                }
                                else
                                {
                                    throw new HTFrameworkException(HTFrameworkModule.Resource, "请求:" + request.url + " 未下载到AB包!");
                                }
                            }
                            else
                            {
                                throw new HTFrameworkException(HTFrameworkModule.Resource, "请求:" + request.url + " 遇到网络错误:" + request.error + "!");
                            }
                        }
                    }
                }
#else
                if (AssetBundles.ContainsKey(info.AssetBundleName))
                {
                    loadingAction?.Invoke(1);
                    yield return(null);

                    asset = AssetBundles[info.AssetBundleName].LoadAsset <T>(info.AssetPath);
                    if (asset)
                    {
                        if (isPrefab)
                        {
                            asset = ClonePrefab(asset as GameObject, parent, isUI);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Resource, "加载资源失败:AB包 " + info.AssetBundleName + " 中不存在资源 " + info.AssetPath + " !");
                    }
                }
                else
                {
                    using (UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(AssetBundleRootPath + info.AssetBundleName, GetAssetBundleHash(info.AssetBundleName)))
                    {
                        request.SendWebRequest();
                        while (!request.isDone)
                        {
                            loadingAction?.Invoke(request.downloadProgress);
                            yield return(null);
                        }
                        if (!request.isNetworkError && !request.isHttpError)
                        {
                            AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);
                            if (bundle)
                            {
                                asset = bundle.LoadAsset <T>(info.AssetPath);
                                if (asset)
                                {
                                    if (isPrefab)
                                    {
                                        asset = ClonePrefab(asset as GameObject, parent, isUI);
                                    }
                                }
                                else
                                {
                                    throw new HTFrameworkException(HTFrameworkModule.Resource, "加载资源失败:AB包 " + info.AssetBundleName + " 中不存在资源 " + info.AssetPath + " !");
                                }

                                if (IsCacheAssetBundle)
                                {
                                    if (!AssetBundles.ContainsKey(info.AssetBundleName))
                                    {
                                        AssetBundles.Add(info.AssetBundleName, bundle);
                                    }
                                }
                                else
                                {
                                    bundle.Unload(false);
                                }
                            }
                            else
                            {
                                throw new HTFrameworkException(HTFrameworkModule.Resource, "请求:" + request.url + " 未下载到AB包!");
                            }
                        }
                        else
                        {
                            throw new HTFrameworkException(HTFrameworkModule.Resource, "请求:" + request.url + " 遇到网络错误:" + request.error + "!");
                        }
                    }
                }
#endif
            }

            DateTime endTime = DateTime.Now;

            Log.Info(string.Format("异步加载资源{0}[{1}模式]:\r\n{2}\r\n等待耗时:{3}秒  加载耗时:{4}秒"
                                   , asset ? "成功" : "失败"
                                   , LoadMode.ToString()
                                   , LoadMode == ResourceLoadMode.Resource ? info.GetResourceFullPath() : info.GetAssetBundleFullPath(AssetBundleRootPath)
                                   , (waitTime - beginTime).TotalSeconds
                                   , (endTime - waitTime).TotalSeconds));

            if (asset)
            {
                DataSetInfo dataSet = info as DataSetInfo;
                if (dataSet != null && dataSet.Data != null)
                {
                    asset.Cast <DataSetBase>().Fill(dataSet.Data);
                }

                loadDoneAction?.Invoke(asset as T);
            }
            asset = null;

            _isLoading = false;
        }
Exemplo n.º 25
0
        public void Start(int ticks)
        {
            Application.targetFrameRate = ticks <= 0 ? 10 : ticks;
            if (IsStarted)
            {
                LogStartedError();
                return;
            }
            else
            {
            }

            Tester = Tester.Instance;
            Tester.Init(new TesterBaseApp());

            AssertFrameworkInit(int.MaxValue);
            AssertFrameworkInit(0);

            Notificater = NotificatonsInt.Instance.Notificater; //new Notifications<int>();//新建消息中心
            ABs         = new AssetBundles();                   //新建资源包管理器
            Servers     = new Servers();                        //新建服务容器管理器
            DataWarehouse datas = new DataWarehouse();          //新建数据管理器

            AssetsPooling = new AssetsPooling();                //新建场景资源对象池
            ECSContext    = new ShipDockComponentContext        //新建 ECS 组件上下文
            {
                FrameTimeInScene = (int)(Time.deltaTime * UpdatesCacher.UPDATE_CACHER_TIME_SCALE)
            };
            StateMachines = new StateMachines//新建有限状态机管理器
            {
                FSMFrameUpdater   = OnFSMFrameUpdater,
                StateFrameUpdater = OnStateFrameUpdater
            };
            Effects             = new Effects();            //新建特效管理器
            Locals              = new Locals();             //新建本地化管理器
            PerspectivesInputer = new PerspectiveInputer(); //新建透视物体交互器
            AppModulars         = new DecorativeModulars(); //新建装饰模块管理器
            Configs             = new ConfigHelper();       //新建配置管理器

            #region 向定制框架中填充框架功能单元
            Framework framework = Framework.Instance;
            FrameworkUnits = new IFrameworkUnit[]
            {
                framework.CreateUnitByBridge(Framework.UNIT_DATA, datas),
                framework.CreateUnitByBridge(Framework.UNIT_AB, ABs),
                framework.CreateUnitByBridge(Framework.UNIT_MODULARS, AppModulars),
                framework.CreateUnitByBridge(Framework.UNIT_ECS, ECSContext),
                framework.CreateUnitByBridge(Framework.UNIT_IOC, Servers),
                framework.CreateUnitByBridge(Framework.UNIT_CONFIG, Configs),
                framework.CreateUnitByBridge(Framework.UNIT_UI, UIs),
                framework.CreateUnitByBridge(Framework.UNIT_FSM, StateMachines),
            };
            framework.LoadUnit(FrameworkUnits);
            #endregion

            mFSMUpdaters   = new KeyValueList <IStateMachine, IUpdate>();
            mStateUpdaters = new KeyValueList <IState, IUpdate>();
            TicksUpdater   = new TicksUpdater(Application.targetFrameRate);//新建客户端心跳帧更新器

            AssertFrameworkInit(1);
            AssertFrameworkInit(2);

            IsStarted = true;
            mAppStarted?.Invoke();
            mAppStarted = default;

            ShipDockConsts.NOTICE_SCENE_UPDATE_READY.Add(OnSceneUpdateReady);
            UpdatesComponent?.Init();

            ShipDockConsts.NOTICE_APPLICATION_STARTUP.Broadcast();//框架启动完成
            AssertFrameworkInit(3);
        }
        private void OnGUI()
        {
            if (whiteStyle == null)
            {
                whiteStyle = new GUIStyle();
                Texture2D img    = new Texture2D(2, 2);
                Color[]   colors = new Color[img.width * img.height];
                for (int i = 0; i < colors.Length; i++)
                {
                    colors[i] = Color.white;
                }
                img.SetPixels(colors);
                img.Apply();
                whiteStyle.normal.background = img;
            }

            if (colorButtonStyle == null)
            {
                colorButtonStyle = new GUIStyle("button");
                colorButtonStyle.normal.background = whiteStyle.normal.background;
                colorButtonStyle.active.background = whiteStyle.normal.background;
                colorButtonStyle.hover.background  = whiteStyle.normal.background;
            }
            if (labelStyle == null)
            {
                labelStyle = new GUIStyle("label");
                labelStyle.normal.textColor = progressMsgColor;
                labelStyle.alignment        = TextAnchor.MiddleCenter;
            }

            Rect rect = new Rect(progressRect);

            rect.x      *= Screen.width;
            rect.y      *= Screen.height;
            rect.width  *= Screen.width;
            rect.height *= Screen.height;

            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), GUIContent.none, whiteStyle);
            GUI.backgroundColor = progressBackgroundColor;
            GUI.Box(rect, GUIContent.none, whiteStyle);
            GUI.backgroundColor = progressForegroundColor;
            GUI.Box(new Rect(rect.x, rect.y, rect.width * progress, rect.height), GUIContent.none, whiteStyle);
            GUI.backgroundColor = Color.white;


            string msg = "", progressText = "";
            string versionStr = "";

            if (!string.IsNullOrEmpty(versionFormat) && AssetBundles.Version != null)
            {
                versionStr = versionFormat.FormatStringWithKey(formatValues);
            }

            switch (AssetBundles.Status)
            {
            case AssetBundleStatus.Downloading:
                if (!string.IsNullOrEmpty(downloadMsgFormat) && AssetBundles.DownloadTotal > 0)
                {
                    msg          = downloadMsgFormat.FormatStringWithKey(formatValues);
                    progressText = downloadProgressFormat.FormatStringWithKey(formatValues);
                }
                break;

            case AssetBundleStatus.Preloading:
                if (!string.IsNullOrEmpty(preloadMsgFormat) && AssetBundles.PreloadedTotal > 0)
                {
                    msg          = preloadMsgFormat.FormatStringWithKey(formatValues);
                    progressText = preloadProgressFormat.FormatStringWithKey(formatValues);
                }
                break;

            case AssetBundleStatus.Error:
                msg = downloadErrorMsg;
                break;
            }

            Vector2 size = labelStyle.CalcSize(new GUIContent(versionStr));

            GUI.Label(new Rect(rect.x, rect.y - size.y, size.x, size.y), versionStr, labelStyle);

            using (new GUILayout.AreaScope(rect, GUIContent.none))
                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(msg, labelStyle, GUILayout.ExpandWidth(false), GUILayout.Height(rect.height));
                    GUILayout.FlexibleSpace();

                    if (AssetBundles.Status == AssetBundleStatus.None || AssetBundles.Status == AssetBundleStatus.Error)
                    {
                        GUI.backgroundColor = retryButtonBackgroundColor;
                        if (GUILayout.Button(retryButtonText, colorButtonStyle, GUILayout.ExpandWidth(false), GUILayout.Height(rect.height)))
                        {
                            AssetBundles.InitializeAsync();
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    else
                    {
                        GUILayout.Label(progressText, labelStyle, GUILayout.ExpandWidth(false), GUILayout.Height(rect.height));
                    }
                }
        }
Exemplo n.º 27
0
 public override void OnApplicationStart()
 {
     AssetBundles.LoadBundle("mono.menu", out UIBundle);
 }
Exemplo n.º 28
0
/*
 *                      private IEnumerator DoForceUpdateCheck()
 *                      {
 *                              // check for forced updates
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Request");
 *                              ForcedUpdate.Init(UrlsToForcedUpdate[0], BuildTag);
 *                              ForcedUpdate.CheckUpdateStatus();
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Waiting for the result");
 *                              DateTime dateTime = DateTime.Now;
 *                              while(ForcedUpdate.IsCheckInProgress())
 *                              {
 *                                      if((DateTime.Now - dateTime).TotalSeconds > kForcedUpdateTimeOut)
 *                                      {
 *                                              Debug.Log("DoContentUpdate - ForcedUpdate - Timed out");
 *                                              break;
 *                                      }
 *                                      yield return null;
 *                              }
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Got result");
 *                              if(ForcedUpdate.NeedToQuit())
 *                              {
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - NeedToQuit");
 *                                      m_shouldBeUpdated = true;
 *                                      if(OnForcedBinariesUpdate != null)
 *                                      {
 *                                              OnForcedBinariesUpdate();
 *                                      }
 *                                      m_isLoadingInProgress = false;
 *                                      yield break;
 *                              }
 *                              else if(ForcedUpdate.NeedToUpdate())
 *                              {
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - NeedToUpdate");
 *                                      if(OnAvailableBinariesUpdate != null)
 *                                      {
 *                                              if(OnAvailableBinariesUpdate())
 *                                              {
 *                                                      m_shouldBeUpdated = true;
 *                                                      m_isLoadingInProgress = false;
 *                                                      yield break;
 *                                              }
 *                                      }
 *                              }
 *                              else
 *                              {
 *                                      if(OnNoNeedBinariesUpdate != null)
 *                                      {
 *                                              OnNoNeedBinariesUpdate();
 *                                      }
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - UpToDate");
 *                              }
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Finished");
 *                      }
 */
            private IEnumerator DoContentUpdate(DynamicContentParam param)
            {
                Debug.Log("DoContentUpdate - Started");

                // check for forced updates
                #region force update from msk

/*
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Request");
 *                              ForcedUpdate.Init(UrlsToForcedUpdate[0], BuildTag);
 *                              ForcedUpdate.CheckUpdateStatus();
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Waiting for the result");
 *                              DateTime dateTime = DateTime.Now;
 *                              while(ForcedUpdate.IsCheckInProgress())
 *                              {
 *                                      if((DateTime.Now - dateTime).TotalSeconds > kForcedUpdateTimeOut)
 *                                      {
 *                                              Debug.Log("DoContentUpdate - ForcedUpdate - Timed out");
 *                                              break;
 *                                      }
 *                                      yield return null;
 *                              }
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Got result");
 *                              if(ForcedUpdate.NeedToQuit())
 *                              {
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - NeedToQuit");
 *                                      m_shouldBeUpdated = true;
 *                                      if(OnForcedBinariesUpdate != null)
 *                                      {
 *                                              OnForcedBinariesUpdate();
 *                                      }
 *                                      m_isLoadingInProgress = false;
 *                                      yield break;
 *                              }
 *                              else if(ForcedUpdate.NeedToUpdate())
 *                              {
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - NeedToUpdate");
 *                                      if(OnAvailableBinariesUpdate != null)
 *                                      {
 *                                              if(OnAvailableBinariesUpdate())
 *                                              {
 *                                                      m_shouldBeUpdated = true;
 *                                                      m_isLoadingInProgress = false;
 *                                                      yield break;
 *                                              }
 *                                      }
 *                              }
 *                              else
 *                              {
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - UpToDate");
 *                              }
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Finished");
 */
                #endregion
                #region ABTesting from msk
                // prepare initial variant data for the resolution

/*
 *                              Debug.Log("DoContentUpdate - ABTesting - Prepare initial variant");
 *                              Dictionary<string, string> initialVariantData = new Dictionary<string, string>();
 *                              initialVariantData.Add(DecisionTable.RESOLUTION_KEY_VARIANT_ID, "DefaultOffline");
 *                              string str = null;
 *                              foreach(string url in UrlsToDefaultAssetBundles)
 *                              {
 *                                      str = (str != null) ? (str + ";" + url) : url;
 *                              }
 *                              initialVariantData.Add("AssetBundlesUrls", str);
 *
 *                              // do A/B testing
 *                              Debug.Log("DoContentUpdate - ABTesting - Request resolution");
 *                              m_resolution = Resolution.Retrieve(initialVariantData, UrlsToABTestingDecisionTable);
 *                              Debug.Log("DoContentUpdate - ABTesting - Waiting for the result");
 *                              while(!m_resolution.Ready)
 *                              {
 *                                      yield return null;
 *                              }
 *                              Debug.Log("DoContentUpdate - ABTesting - Resolved");
 *
 *                              // unload previously loaded asset bundles
 *                              if(m_indexInfo != null && !param.IsAddonContent)
 *                              {
 *                                      Debug.Log("DoContentUpdate - AssetBundles - Unload previously loaded ones");
 *                                      m_indexInfo.UnloadAll(true);
 *                              }
 *
 *                              bool success = false;
 #if !ASSET_BUNDLE_FORCE_ONLINE
 *                              Assertion.Check(m_resolution.Data != null, "DoContentUpdate - Retrieved ABTesting variant data are corrupted");
 #endif
 */
                #endregion

                #region Get Asset bundles list from server
                bool success = false;
//				Debug.Log("Get Asset Bundles list from: "+UrlToDynamicContentInfo);
//				DynamicContentInfo DCInfo = new DynamicContentInfo(UrlToDynamicContentInfo);
//				StartCoroutine(DCInfo.StartDownloadContent());
//				while(!DCInfo.Ready)
//				{
//					yield return null;
//				}
//				Hashtable assetBundleInfo = DCInfo.Result;
                #endregion

//				if((m_resolution.Data != null) && m_resolution.Data.ContainsKey("AssetBundlesUrls"))
                if (param.DCInfoCache != null)
                {
                    // load asset bundles
                    Debug.Log("DoContentUpdate - AssetBundles - Download");
                    //make multi-version files
                    string[] orgVersionFileUrls = param.DCInfoCache.AssetBundleList.ToArray(typeof(string)) as string[];
//					if(param != null && param.ContentType == DynamicContentParam.EnumContentType.CT_SPECIAL_INDEX)
//					{
                    string curVersionFileUrl = param.CheckAllSpecialIndexNameValid(orgVersionFileUrls);
                    Assertion.Check(!string.IsNullOrEmpty(curVersionFileUrl), "DoContentUpdate- Wrong Special Index Name" + param.SpecialIndexName);

//					}
//					else
//					{
//						versionFileUrls = orgVersionFileUrls;
//					}

//					if (versionFileUrls == null)
//					{
//						Debug.LogWarning("No Asset Bundle is need update");
//						success = true;
//					}
//					else
//					{
                    LogEventStarted(curVersionFileUrl);
                    string[] temp = { curVersionFileUrl };
                    m_indexInfo = AssetBundles.DownloadAll(temp);
                    param.TargetIndexDownloadInfo.IndexDownloadInfo = m_indexInfo;
                    m_isIndexInfo = true;
                    Debug.Log("DoContentUpdate - AssetBundles - Waiting for the result");
                    while (m_indexInfo.state == IndexInfo.State.InProgress)
                    {
                        yield return(null);
                    }

                    LogEventEnded(m_indexInfo);
                    Debug.Log(string.Format("DoContentUpdate - AssetBundles - Downloaded with result: {0}, from: {1}", m_indexInfo.state, m_indexInfo.source));
                    switch (m_indexInfo.state)
                    {
                    case IndexInfo.State.Failed:
                        success = false;
                        break;

                    case IndexInfo.State.Succeeded:
                        success = true;
                        break;

                    default:
                        // SANITY CHECK
                        Assertion.Check(false);
                        break;
                    }
                    //}
                }
                else
                {
                    success = false;
                }

//				if(success)
//				{
//					Assertion.Check(CustomDynamicContent != null);
//					if((CustomDynamicContent != null) && (CustomDynamicContent.Count > 0))
//					{
//						// load optional configs
//						Debug.Log("DoContentUpdate - CustomUpdate");
//						foreach(ICustomDynamicContent customDynamicContent in CustomDynamicContent)
//						{
//							customDynamicContent.StartContentUpdate(m_resolution);
//							while(customDynamicContent.IsInProgress)
//							{
//								yield return null;
//							}
//							success &= customDynamicContent.Result;
//						}
//						Debug.Log("DoContentUpdate - CustomUpdate is finished with result: {0}", success);
//					}
//					else
//					{
//						success = true;
//					}
//				}
//
//				if(success)
//				{
//					Debug.Log("DoContentUpdate - ABTesting - Commiting variant");
//					success = m_resolution.Commit();
//				}

                Debug.Log("DoContentUpdate - Overall result is {0}");
                if (success)
                {
                    if (OnSuccess != null)
                    {
                        Debug.Log("DoContentUpdate - OnSuccess");
                        OnSuccess();
                    }
                }
                else
                {
                    if (OnFail != null)
                    {
                        Debug.Log("DoContentUpdate - OnFail");
                        OnFail();
                    }
                }

                // finish
                m_shouldBeUpdated     = false;
                m_isLoadingInProgress = false;
                //m_wasOneLoadAtLeast = true;
                Debug.Log("DoContentUpdate - Finished");
                yield break;
            }