protected void InitWidget() { { if (BtnClose == null) { Transform CloseTrans = GetTransform().FindChild("Frame/BtnClose"); if (CloseTrans != null) { BtnClose = CloseTrans.GetComponent <Button>(); } else { Trace.LogError("没找到对象名为:BtnClose 的按钮"); } } if (BtnClose == null) { Trace.LogError("对象名为:BuyBtn 没找到Button组件"); } else { BtnClose.onClick.AddListener(OnBtnCloseClick); } } //初始化按钮组 { UWarGoodsStoreTabItem RecommendItem = SetGoodsStoreTabItem("WarGoodsStore", "RecommendGoods", 0, OnBtnRecommendSelected); if (RecommendItem != null) { GoodsStoreTab.SetSelectedItem(RecommendItem, true); } SetGoodsStoreTabItem("WarGoodsStore", "AllGoods", -1, OnBtnAllSelected); } }
/// <summary> /// 创建顶部标签元素 /// </summary> /// <returns></returns> public UWarGoodsStoreTabItem SetGoodsStoreTabItem(string _strLocalFilter, string _strLocalKey, int _nDispositionID, UnityAction <UButtonGroupItem, bool> _actionSelected) { UWarGoodsStoreTabItem tmpItem = ResNode.InstantiateRes <UWarGoodsStoreTabItem>(DefaultTabItem.gameObject, true); if (tmpItem != null) { tmpItem.gameObject.SetActive(true); tmpItem.Init(_strLocalFilter, _strLocalKey, _nDispositionID, _actionSelected, GoodsStoreTab); } return(tmpItem); }
// 推荐物品按钮选择 public void OnOtherTabItemSelected(UButtonGroupItem _item, bool _bSelect) { if (_bSelect) { SwitchSubWndPage(EGoodsStoreSubView.EGSSV_RecommendGoods, _bSelect); UWarGoodsStoreTabItem tmpItem = _item as UWarGoodsStoreTabItem; if (tmpItem != null && DispositionGoodsView != null) { //因为前两个TabItem序号是默认推荐物品(0)和所有物品(1),所以,序号需要往前移1位 DispositionGoodsView.OnDispositionSelect(tmpItem.ItemIndex - 1); } } }
/// <summary> /// 根据物品配置ID设置对应的推荐物品配置标签元素选择 /// </summary> /// <param name="_nDispositionID"></param> public void SetGoodsStoreTabItemSelected(int _nDispositionID) { for (int i = 0; i < GoodsStoreTab.Length(); ++i) { UWarGoodsStoreTabItem item = GoodsStoreTab.GetItemAt(i) as UWarGoodsStoreTabItem; if (item != null) { if (item.DispositionID == _nDispositionID) { item.Selected = true; return; } } } }