public void OnUICmdItemTouchUp(UICmdItem item, PointerEventData eventData) { Vector2 posScreen = eventData.position; Transform parent = uiCmdBarRun.GetItemParent(item); if (parent != null) { //命令移动到run bar上面 item.transform.parent = parent; RectTransform rt = item.GetComponent <RectTransform>(); rt.anchoredPosition = Vector2.zero; return; } Debug.Log("posScreen =" + posScreen + " item.posTouchDown=" + item.posTouchDown); float action_time = 1f; RectTransform rctran = item.GetComponent <RectTransform>(); Vector2 pt = item.localPosNormal; item.transform.parent = this.transform; rctran.DOLocalMove(pt, action_time).SetEase(Ease.InOutSine).OnComplete( () => { Debug.Log("rctran.localPosition=" + rctran.localPosition); // item.ShowTextCount(true); OnDragAnimateFinish(); // LayOutItem(); } ); }
public void AddItem(UICmdItem.CmdType type) { int idx = listItem.Count; UICmdItem cmdItem = (UICmdItem)GameObject.Instantiate(uiCmdItemPrefab); cmdItem.transform.parent = objScrollViewContent.transform; //this.transform; cmdItem.transform.localScale = new Vector3(1, 1, 1); cmdItem.transform.localPosition = new Vector3(0, 0, 0); cmdItem.index = idx; cmdItem.cmdType = type; cmdItem.callBackTouch = OnUITouchEvent; cmdItem.UpdateItem(); //更新scrollview 内容的长度 RectTransform rctranItem = cmdItem.GetComponent <RectTransform>(); RectTransform rctran = objScrollViewContent.GetComponent <RectTransform>(); Vector2 size = rctran.sizeDelta; widthItem = rctranItem.rect.width; Debug.Log("widthItem=" + widthItem); size.x = widthItem * (idx + 1); rctran.sizeDelta = size; listItem.Add(cmdItem); }
public void OnUICmdItemTouchUp(UICmdItem item, PointerEventData eventData) { Vector2 posScreen = eventData.position; //恢复位置动画 // iTween.MoveTo(item.gameObject, iTween.Hash("position", item.posTouchDown, "time", 1f, "easeType", iTween.EaseType.easeInQuint)); float action_time = 1f; RectTransform rctran = item.GetComponent <RectTransform>(); Vector2 pt = item.posTouchDown; // rctran.DOMove(pt, action_time).SetEase(Ease.InOutSine).OnComplete( () => { item.transform.parent = objScrollViewContent.transform; LayOutItem(); } ); }