/// <summary> /// Create a UI /// </summary> /// <param name="p_type">UI category: fullscreen, window, popup, etc</param> /// <param name="p_name">name you defined</param> /// <param name="p_mediatorType"></param> /// <param name="p_bundlePath">prefab to instantiate</param> /// <param name="p_viewInitCallBack"></param> /// <param name="p_viewRefreshCallBack"></param> /// <param name="p_allocateDepth">allocate several panel depth to ui</param> /// <param name="p_viewName"></param> /// <param name="isShowAnimation"></param> private void CreateUI(UIItemConfig p_config, DelegateHelper.TableDelegate p_viewInitCallBack, DelegateHelper.TableDelegate p_viewRefreshCallBack = null, bool isShowAnimation = true) { try { if (!m_UICategoryMap.ContainsKey(p_config.Type)) { throw new KeyNotFoundException(string.Format("Key: {0} not found in UI Category.", p_config.Type)); } if (p_config.BundleName == null) { throw new Exception("Cannot create UI cause no res provided."); } Game.StartCoroutine(GameAssets.LoadAssetAsync <GameObject>(p_config.BundleName, p_config.AssetName, (prefab) => { CreateUIInternal(p_config, prefab, p_viewInitCallBack, p_viewRefreshCallBack, isShowAnimation); })); GameAssets.AddBundleRef(p_config.BundleName); } catch (Exception e) { LogModule.ErrorLog("Exception in create UI, {0}\n{1}", e.Message, e.StackTrace); return; } }
public void OnInit() { if (View == null) { Game.StartCoroutine(GameAssets.LoadAssetAsync <GameObject>(BattleUIView.BundleName, BattleUIView.AssetName, (prefab) => { var ins = Object.Instantiate(prefab); Utils.StandardizeObject(ins); if (View == null) { View = ins.GetComponent <BattleUIView>(); } AddListener(); var troopList = GameFacade.GetProxy <BattleProxy>().BattleInfor.objList.Where(item => item.skilldataid != null && item.skilldataid.Any()).Select(item => item.id).ToList(); for (int i = 0; i < troopList.Count; i++) { SkillIndexToTroopIndex.Add(i, troopList[i]); } IsInited = true; })); GameAssets.AddBundleRef(BattleUIView.BundleName); } else { IsInited = true; } }