public virtual void OnDragToolBegin(UGUIDrag drag, PointerEventData eventData) { OnToolPreStart.Invoke(); OnToolStart.Invoke(); }
void Update() { if (_mode == Mode.DragTool) { return; } if (false == _isSelected) { return; } if (true == _isStopFingerTouch) { return; } if (Input.GetMouseButtonDown(0)) { if (true == _isCheckOnUI && true == InputUtil.CheckMouseOnUI()) { return; } if (false == _isFingerMoved) { _hasStartDraw = true; _mousePressPos = Input.mousePosition; if (_operation == Operation.DrawLine) { LoopPainter((RenderTexturePainter painter) => { painter.ClickDraw(_mousePressPos, null, null, painter._brushScale); }); } else { StartDragPaint(); } } _hasDoEndDrawActions = false; MouseButtonDownAction(); OnToolStart.Invoke(); _drag.PlaySoundStartDrag(); } if (Input.GetMouseButton(0) && false == _hasDoEndDrawActions) { if (false == _isFingerMoved) { if (Vector3.Distance(Input.mousePosition, _mousePressPos) > 10) { _isFingerMoved = true; } } if (null != _finger && true == _isHideFingerOnMove) { _finger.DOKill(); _finger.enabled = false; } if (true == _isFingerMoved) { bool isUseChecker = false; foreach (PainterChecker checker in _listChecker) { if (true == checker._isUseChecker) { isUseChecker = true; break; } } if (false == isUseChecker) { OnInArea.Invoke(true); SetDragEffectPlay(true); } } if (true == _isFingerMoved && null != _finger) { bool ret = RectTransformUtility.ScreenPointToLocalPointInRectangle(_finger.transform.parent.GetComponent <RectTransform>(), Input.mousePosition, Camera.main, out Vector2 localPoint); if (ret) { if (_finger.transform.GetSiblingIndex() == _finger.transform.parent.childCount - 1) { _finger.GetComponent <RectTransform>().anchoredPosition = localPoint; Vector3 toPos = Camera.main.WorldToScreenPoint(_finger.transform.position); LoopPainter((RenderTexturePainter painter) => { painter.Drawing(toPos); }); UpdateCheckPoint(toPos); } } } else { Vector3 toPos = Input.mousePosition; if (_arrayDrawMainTex.Length > 0) { Texture tex = _arrayDrawMainTex[Random.Range(0, _arrayDrawMainTex.Length)]; toPos.x = toPos.x - 5 + 10 * Random.Range(0f, 1f); toPos.y = toPos.y - 5 + 10 * Random.Range(0f, 1f); float scale = 0.8f + Random.Range(0f, 1f); LoopPainter((RenderTexturePainter painter) => { painter.ClickDraw(toPos, null, tex, scale); }); } else { LoopPainter((RenderTexturePainter painter) => { painter.Drawing(toPos); }); } UpdateCheckPoint(toPos); } MouseButtonMovingAction(); } if (Input.GetMouseButtonUp(0)) { OnInArea.Invoke(false); SetDragEffectPlay(false); if (true == _hasStartDraw) { _hasStartDraw = false; _drag.PlaySoundEndDrag(); if (true == _isFingerMoved) { _isFingerMoved = false; MouseButtonUpAction(); OnToolEnd.Invoke(); } EndDragPaint(); } } }