public void InitMail(int threenum, Text content) { if (Addres == null) { Addres = Addresser_txt.GetComponent <RectTransform>(); MailWard = MailWardContent_txt.GetComponent <RectTransform>(); threetallmrec = Currency_trf.GetComponent <RectTransform>(); mailitemrec = MailItem_trf.GetComponent <RectTransform>(); Adjunct = Adjunct_obj.GetComponent <RectTransform>(); Content = Content_obj.GetComponent <RectTransform>(); //NoticeMatter = NoticeMatter_txt.GetComponent<RectTransform>(); //NoticeAddresser = NoticeAddresser_txt.GetComponent<RectTransform>(); //Notice = Notice_obj.GetComponent<RectTransform>(); //NoticeName = NoticeName_obj.GetComponent<RectTransform>(); } string ids = content.text; content.text = string.Empty; height = content.preferredHeight; //一行文字的高度 content.text = ids; float line = content.preferredHeight / height; MailWard.offsetMin = new Vector2(0, -line * height); Addres.anchoredPosition = new Vector2(0, MailWard.offsetMin.y * 1.1f); Adjunct.anchoredPosition = new Vector2(0, Addres.anchoredPosition.y + -height + -Addres.rect.size.y); threetallmrec.anchoredPosition = new Vector2(0, -height); mailitemrec.anchoredPosition = new Vector2(0, -(threenum * ThreeTall) + -height); Content.offsetMin = new Vector2(0, Addres.anchoredPosition.y); Content.offsetMax = Vector2.zero; }
public override void Awake() { base.Awake(); workerGo = new Dictionary <EWORKER, GameObject> { { EWORKER.Worker_fangyu, Fangyu_obj }, { EWORKER.Worker_fuzhu, Fuzhu_obj }, { EWORKER.Worker_gongshou, Gongshou_obj }, { EWORKER.Worker_shuchu, Shuchu_obj }, { EWORKER.Worker__moushi, Moushi_obj } }; gle = Content_obj.GetComponent <GridLayerExpand>(); sr = ScrollView_obj.GetComponent <ScrollRect>(); rt = Content_obj.GetComponent <RectTransform>(); lockobj = Instantiate(Lock, transform, false).transform; HeroData[] allHero = HeroMgr.GetSingleton().Heros; //英雄分类 heroGo = new Dictionary <HeroInfo, Transform>(); for (int i = allHero.Length - 1; i >= 0; --i) { EWORKER worker = (EWORKER)allHero[i].JsonData.type; GameObject info = Instantiate(HeadInfo, workerGo[worker].transform, false); HeroInfo heroInfo = info.GetComponent <HeroInfo>(); heroInfo.SetData(allHero[i]); EventListener.Get(info).OnClick = e => { if (isDrag) { return; } UIFace.GetSingleton().Open(UIID.HeroDetail, heroInfo.heroData.HeroId); }; EventListener.Get(info).BegineDragEvent = e => { isDrag = true; sr.OnBeginDrag(e); }; EventListener.Get(info).DragEvent = e => { sr.OnDrag(e); }; EventListener.Get(info).EndDragEvent = e => { isDrag = false; sr.OnEndDrag(e); }; heroGo.Add(heroInfo, info.transform); } foreach (var item in workerGo) { item.Value.SetActive(false); } //图片分类 imageWorker = new Dictionary <GameObject, EWORKER> { { all_img.gameObject, EWORKER.ALL }, { shuchu_img.gameObject, EWORKER.Worker_shuchu }, { fangyu_img.gameObject, EWORKER.Worker_fangyu }, { gongshou_img.gameObject, EWORKER.Worker_gongshou }, { fuzhu_img.gameObject, EWORKER.Worker_fuzhu }, { moushi_img.gameObject, EWORKER.Worker__moushi } }; TriggerListenr(); }