private void InitHeroHead() { List <int> HeroList = GetShowHerolist(HeroType.AllHero); foreach (int hero in HeroList) { ResourceItem objHomeBaseUnit = ResourcesManager.Instance.loadImmediate(GameConstDefine.LoadHeroDataPhoto, ResourceType.PREFAB); GameObject obj = GameObject.Instantiate(objHomeBaseUnit.Asset) as GameObject; obj.transform.parent = mGrid.transform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; HeroDataPhoto hdp = new HeroDataPhoto(); hdp.mRoot = obj; hdp.mHeroNick = obj.transform.Find("Name").GetComponent <UILabel>(); hdp.mHeroIcon = obj.transform.Find("Photo").GetComponent <UISprite>(); hdp.mOwn = obj.transform.Find("IsOwn").gameObject; hdp.mLastTime = obj.transform.Find("LastTime").GetComponent <UILabel>(); hdp.mGray = obj.transform.Find("Gray").GetComponent <UISprite>(); UIEventListener.Get(obj).onClick += hdp.OnItemSelect; HeroDataList.Add(hdp); } }
/// <summary> /// 根据类型显示英雄资料 /// </summary> /// <param name="type"></param> private void ShowHeroDatum(HeroType type) { List <int> HeroList = GetShowHerolist(type); if (HeroList.Count == 0) { return; } for (int mCount = 0; mCount < HeroDataList.Count; mCount++) { HeroDataPhoto data = HeroDataList[mCount]; if (mCount >= HeroList.Count) { data.mRoot.SetActive(false); continue; } data.mRoot.SetActive(true); data.ShowHeroData(HeroList[mCount]); } mGrid.repositionNow = true; mGrid.Reposition(); mScroll.ResetPosition(); }