/// <summary> /// 放开Item /// </summary> /// <param name="evenData"></param> /// <param name="obj"></param> /// <param name="etl"></param> public void UpItem(PointerEventData evenData, GameObject obj, DownUpEvent etl) { if (evenData.pointerId != _pointerId || _isDraging || _canMoving == false) { return; } _pointerId = 100; ItemStateBack(); }
/// <summary> /// 按下按钮 /// </summary> /// <param name="ms"></param> /// <param name="tf"></param> /// <param name="etl"></param> private void DownButton(MoveState ms, Transform tf, DownUpEvent etl) { if (_isMoving) { return; } _isMoving = true; _moveState = ms; ButtonEffect.Scale(tf, delegate { etl.enabled = true; Moving(); }); }
public static DownUpEvent Get(GameObject go) { DownUpEvent listener = go.GetComponent <DownUpEvent>(); if (listener == null) { listener = go.AddComponent <DownUpEvent>(); } return(listener); }
/// <summary> /// 按下按钮 /// </summary> /// <param name="ms"></param> /// <param name="tf"></param> /// <param name="etl"></param> private void DownButton(MoveState ms, Transform tf, DownUpEvent etl) { if (_isMoving || _canMoving == false) { return; } _isMoving = true; _moveState = ms; ButtonEffect.Scale(tf, Moving, 1.4f); }
private void Awake() { DownUpEvent.Get(_prevButton)._downAction = DownPrevButton; DownUpEvent.Get(_nextButton)._downAction = DownNextButton; _currentPage.Init(this); _nextPage.Init(this); if (_totalItemNum != 0) { Init(_totalItemNum); } }
/// <summary> /// 添加事件 /// </summary> private void AddEvent() { _canMoving = true; DownUpEvent.Get(_prevButton)._downAction = DownPrevButton; DownUpEvent.Get(_nextButton)._downAction = DownNextButton; for (int i = 0; i < _itemList.Count; i++) { DownUpEvent.Get(_itemList[i])._downAction = DownItem; DownUpEvent.Get(_itemList[i])._upAction = UpItem; } UpdateButton(); }
/// <summary> /// 按下Item /// </summary> /// <param name="evenData"></param> /// <param name="obj"></param> /// <param name="etl"></param> public void DownItem(PointerEventData eventData, GameObject obj, DownUpEvent etl) { if (_canMoving == false || _pointerId != 100) { return; } _pointerId = eventData.pointerId; _chosedItem = obj; if (_downStateAction != null) { _downStateAction(_chosedItem); } }
/// <summary> /// 下一页 /// </summary> /// <param name="evenData"></param> /// <param name="obj"></param> /// <param name="etl"></param> private void DownNextButton(PointerEventData evenData, GameObject obj, DownUpEvent etl) { DownButton(MoveState.一页, obj.transform, etl); }