protected override void ItemAddListion(UGUIItemFunction func) { base.ItemAddListion(func); MaterailImageItemFunc itemfun = func as MaterailImageItemFunc; itemfun.deleFun = DeleFun; itemfun.deleFollowMouse = FollowMouse; itemfun.deleSetDraggedPosition = SetDraggedPosition; itemfun.deleSetDraggingIcon = SetDraggingIcon; itemfun.deleEndDragCopy = EndDragCopy; }
public void DeleFun(MaterailImageItemFunc itemFunc) { ItemData item = itemFunc.data; Msgs.Remove(item); if (Msgs.Count >= 6) { transform.GetComponent <RectTransform>().sizeDelta = new Vector2(ContentRectTrans.sizeDelta.x, CellHeight * 6 + CellHeightSpace * (6)); MaterialController.sizeDelta = new Vector2(GetLoaclPosByIndex(6).x, -GetLoaclPosByIndex(6).y + 60); } else { transform.GetComponent <RectTransform>().sizeDelta = new Vector2(ContentRectTrans.sizeDelta.x, CellHeight * (Msgs.Count) + CellHeightSpace * (Msgs.Count)); MaterialController.sizeDelta = new Vector2(GetLoaclPosByIndex(Msgs.Count + 1).x, -GetLoaclPosByIndex(Msgs.Count + 1).y + 60); } Debug.Log(MaterialController.sizeDelta); RefreshDisplay(null, false, true); dispatchEvent(new MaterialEvent(MaterialEvent.RemoveMaterial, item)); }
public override void RefreshDisplay(List <ItemData> data = null, bool restPos = false, bool isChange = false) { //base.RefreshDisplay(data, restPos, isChange); //if (!isAdd) //{ foreach (UGUIItemFunction item in itemDic.Values) { item.gameObject.SetActive(false); skinList.Push(item.gameObject); } //} itemDic.Clear(); if (restPos == true) { ResetPostion(); } if (data != null) { this.Msgs = data; } if (data != null || isChange) { SetContentSize(this.Msgs.Count + 2); } int index = 0; if (specialskin == null) { specialskin = GetInstance(); Debug.Log(specialskin); UITool.SetActionTrue(specialskin); } specialskin.transform.SetParent(ContentRectTrans); specialskin.transform.localPosition = GetLoaclPosByIndex(index); specialskin.transform.localScale = Vector3.one; specialskin.GetComponent <RectTransform>().SetSiblingIndex(index); MaterailImageItemFunc itemfunc = specialskin.GetComponent <MaterailImageItemFunc>(); itemfunc.scroRect = ScroRect; itemfunc.data = specialitem; itemfunc.index = index; ItemAddListion(itemfunc); // ItemChildGameObject(specialskin); for (int i = 0; i < this.Msgs.Count; i++) { if ((i < CurrentIndex - UpperLimitIndex) && (CurrentIndex > LowerLimitIndex) && !isChange) { return; } skinClone = GetInstance(); skinClone.transform.SetParent(ContentRectTrans); skinClone.transform.localPosition = GetLoaclPosByIndex(i + AddItemPerfab); skinClone.transform.localScale = Vector3.one; skinClone.GetComponent <RectTransform>().SetSiblingIndex(i + AddItemPerfab); MaterailImageItemFunc func = skinClone.GetComponent <MaterailImageItemFunc>(); func.scroRect = ScroRect; func.data = this.Msgs[i]; func.index = i + AddItemPerfab; itemDic.Add(i + AddItemPerfab, func); ItemAddListion(func); ItemChildGameObject(skinClone); } if (specialBottomskin == null) { specialBottomskin = GetInstance(); Debug.Log(specialskin); UITool.SetActionTrue(specialBottomskin); } specialBottomskin.transform.SetParent(ContentRectTrans); specialBottomskin.transform.localPosition = GetLoaclPosByIndex(this.Msgs.Count + 1); specialBottomskin.transform.localScale = Vector3.one; specialBottomskin.GetComponent <RectTransform>().SetSiblingIndex(this.Msgs.Count + 1); MaterailImageItemFunc itemBottomFunc = specialBottomskin.GetComponent <MaterailImageItemFunc>(); itemBottomFunc.scroRect = ScroRect; itemBottomFunc.data = specialitemBottom; itemBottomFunc.index = index + 1; ItemAddListion(itemBottomFunc); // 容器的区域限制 if (data != null || isChange == true) { int length = Msgs.Count; if (length >= 6) { ScrollRectTrans.sizeDelta = new Vector2(ContentRectTrans.sizeDelta.x, CellHeight * 6 + CellHeightSpace * (6)); MaterialController.sizeDelta = new Vector2(GetLoaclPosByIndex(6).x, -GetLoaclPosByIndex(6).y + 60); } else { ScrollRectTrans.sizeDelta = new Vector2(ContentRectTrans.sizeDelta.x, CellHeight * (length + 1) + CellHeightSpace * (length + 1)); MaterialController.sizeDelta = new Vector2(GetLoaclPosByIndex(length + 1).x, -GetLoaclPosByIndex(length + 1).y + 60); } //MaterialController.sizeDelta = new Vector2(GetLoaclPosByIndex(length).x, -GetLoaclPosByIndex(length).y + 60); } }