// 触发添加按钮 // 移除相机 视图 protected override void ItemAddListion(UGUIItemFunction func) { base.ItemAddListion(func); CamereViewItemFunc itemfun = func as CamereViewItemFunc; itemfun.deleFun = DeleFun; //itemfun.deleFollowMouse = FollowMouse; //itemfun.deleSetDraggedPosition = SetDraggedPosition; //itemfun.deleSetDraggingIcon = SetDraggingIcon; //itemfun.deleEndDragCopy = EndDragCopy; }
private void DeleFun(CamereViewItemFunc itemFunc) { undoHelper.save(); int index = itemFunc.index; Msgs.RemoveAt(index); //if (Msgs.Count >= 3) //{ // ScrollRectTrans.sizeDelta = new Vector2(ContentRectTrans.sizeDelta.x, CellHeight * 6 + CellHeightSpace * (6)); // //controllerAddDelet.sizeDelta = new Vector2(GetLoaclPosByIndex(6).x, -GetLoaclPosByIndex(6).y + 60); //} //else //{ // ScrollRectTrans.sizeDelta = new Vector2(ContentRectTrans.sizeDelta.x, CellHeight * (Msgs.Count) + CellHeightSpace * (Msgs.Count)); // //controllerAddDelet.sizeDelta = new Vector2(GetLoaclPosByIndex(Msgs.Count + 1).x, -GetLoaclPosByIndex(Msgs.Count + 1).y + 60); //} ////MaterialController.sizeDelta = new Vector2(GetLoaclPosByIndex(Msgs.Count).x, -GetLoaclPosByIndex(Msgs.Count).y + 60); ////RefreshDisplay(Msgs, false, true); //Debug.Log(ScrollRectTrans.sizeDelta); RefreshDisplay(null, false, true); dispatchEvent(new CameraViewEvent(CameraViewEvent.RemoveCameraView, itemFunc.data)); }
public override void RefreshDisplay(List <ItemData> data = null, bool restPos = false, bool isChange = false) { 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); } 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); skinClone.transform.localScale = Vector3.one; skinClone.GetComponent <RectTransform>().SetSiblingIndex(i); CamereViewItemFunc func = skinClone.GetComponent <CamereViewItemFunc>(); func.scroRect = ScroRect; func.data = this.Msgs[i]; func.index = i; func.deleClick = ClickItem; itemDic.Add(i, func); ItemAddListion(func); func.delete.gameObject.SetActive(isPress); } // 容器的区域限制 if (data != null || isChange == true) { int length = Msgs.Count; if (length >= 3) { ScrollRectTrans.sizeDelta = new Vector2(ContentRectTrans.sizeDelta.x, CellHeight * 3 + CellHeightSpace * (2)); //controllerAddDelet.sizeDelta = new Vector2(GetLoaclPosByIndex(6).x, -GetLoaclPosByIndex(6).y + 60); } else if (length == 0) { ScrollRectTrans.sizeDelta = new Vector2(ContentRectTrans.sizeDelta.x, 120); } else { ScrollRectTrans.sizeDelta = new Vector2(ContentRectTrans.sizeDelta.x, CellHeight * length + CellHeightSpace * length); //controllerAddDelet.sizeDelta = new Vector2(GetLoaclPosByIndex(length).x, -GetLoaclPosByIndex(length).y + 60); } //MaterialController.sizeDelta = new Vector2(GetLoaclPosByIndex(length).x, -GetLoaclPosByIndex(length).y + 60); } }