using Gameplay; using PhxhSDK; using System; using System.Collections.Generic; using TMPro; using UnityEngine; public class UI_PatioController : UIWindow { //UI GameObj ///Auto Gen Start/// ///Auto Gen End/// // Use this for initialization List mShopDataList; PhxhScrollView _mCurrentScrollView = null; private GameObject mCurrentScrollViewContentObj = null; Dictionary mShopItemGoDataDic; public override void OnInit() { //bind UI GameObj UI_PatioBinder.GetComponents(this); mShopDataList = new List(); _mCurrentScrollView = GetComponent("Scroll View"); mCurrentScrollViewContentObj = FindObj("Scroll View/Viewport/Content"); } //invoke when open window protected override void OnShowWindow(object data) { NormalShopDataForGacha nowShopData = data as NormalShopDataForGacha; mShopDataList = nowShopData.normalShopItemDatas; CreateScrollView(); } private void CreateScrollView() { if (null != mCurrentScrollViewContentObj) { CommonUtils.DestoryAllChildGameObject(mCurrentScrollViewContentObj); } SetScrollView(); RefreshScrollview(); } private void SetScrollView() { _mCurrentScrollView.SetUpdateFunc(RefreshItem); _mCurrentScrollView.SetItemCountFunc(GetCountFunc); _mCurrentScrollView.SetButton(SetScrollviewItemButton); } private void RefreshScrollview() { _mCurrentScrollView.UpdateData(false); } private int GetCountFunc() { return mShopDataList.Count; } private void SetScrollviewItemButton(GameObject obj) { GameObject singleObj = CommonUtils.GetGameObject(obj, "ClickBtn"); ClearBind(singleObj); BindButton(singleObj, OnShopItemClick, singleObj); } private void OnShopItemClick(GameObject obj) { NormalShopItemData info = mShopItemGoDataDic[obj]; //await UIManager.Instance.OpenWindow(UINameConst.UI_Purchase, shopItemContainPic); } private void RefreshItem(int index, RectTransform item) { item.gameObject.SetActive(true); NormalShopItemData normalShopData = mShopDataList[index]; RefreshSingleItem(item.gameObject,normalShopData); mShopItemGoDataDic[item.gameObject]= normalShopData; } private void RefreshSingleItem(GameObject gameObject, NormalShopItemData normalShopData) { var uiHeadInfo = new UIHeadInfo((uint)CommonUtils.GetItemCharacterCfgId(normalShopData.id), false) { // ClickCb = (Action)OnClickItem, IsShowBg = false }; UIHeadItemNode headItemNode = CommonUtils.GetComponent(gameObject, "Head/UIHeadItemNode"); headItemNode.GetComponents(); headItemNode.SetData(uiHeadInfo); //headItemNode.SetClickCbParam(index); headItemNode.Refresh(false); CommonUtils.GetComponent(gameObject, "Price").text = normalShopData.price.ToString(); } //invoke when reload window protected override void OnReloadWindow(object data = null) { } //invoke when close window protected override void OnHideWindow() { } }