Beispiel #1
0
        public bool OnBeginDrag(PointerEventData eventData)
        {
            Vector2 localPoint;

            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.pressPosition, eventData.pressEventCamera, out localPoint))
            {
                if (Vector2.Distance(Vector2.zero, localPoint) <= _pointRadius + _pointSkin)
                {
                    _isDraggingPoint = true;
                    OnDragBegin?.Invoke(this, new EventArgs(eventData, isPointEvent: true));
                    SetDraggedPosition(eventData);
                }
                else if (Vector2.Distance(localPoint, _outHandlePosition) <= _handleRadius + _handleSkin)
                {
                    _isDraggingOutHandle = true;
                    OnDragBegin?.Invoke(this, new EventArgs(eventData, isOutHandleEvent: true));
                    SetDraggedAngle(eventData);
                }
                else if (Vector2.Distance(localPoint, _inHandlePosition) <= _handleRadius + _handleSkin)
                {
                    _isDraggingInHandle = true;
                    OnDragBegin?.Invoke(this, new EventArgs(eventData, isInHandleEvent: true));
                    SetDraggedAngle(eventData);
                }
                else
                {
                    return(!IsEventOutside(eventData));
                }

                return(true);
            }

            return(false);
        }
        private void Timeline_MouseDown(object sender, MouseEventArgs e)
        {
            var rect = new RectangleF(SideRenderOffset, Height / 2 - BarWidth / 2 - 1, (Width - SideRenderOffset * 2) + 1, BarWidth + 2);

            if (rect.Contains(e.Location))
            {
                _dragging = true;

                OnDragBegin.Invoke(this, null);
                Timeline_MouseMove(sender, e);
            }
        }
Beispiel #3
0
 private void Drag()
 {
     if (!isActive)
     {
         return;
     }
     if (!isUse)
     {
         assembleManager.OnSelect.Invoke(this);
         PrepareAssmeble();
     }
     else if (prepareFinish)
     {
         if (Input.GetMouseButtonDown(0))
         {
             Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             RaycastHit hit;
             containerBase = null;
             if (Physics.Raycast(ray, out hit, 100) && hit.transform.name == obj.name)
             {
                 screenPosition  = Camera.main.WorldToScreenPoint(obj.transform.position);
                 mScreenPosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPosition.z);
                 offset          = obj.transform.position - Camera.main.ScreenToWorldPoint(mScreenPosition);
                 isButtonDown    = true;
             }
             if (OnDragBegin != null)
             {
                 OnDragBegin.Invoke();
             }
         }
         if (Input.GetMouseButton(0) && isButtonDown)
         {
             mScreenPosition        = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPosition.z);
             obj.transform.position = Camera.main.ScreenToWorldPoint(mScreenPosition) + offset;
         }
         if (Input.GetMouseButtonUp(0) && isButtonDown)
         {
             isUse         = false;
             isActive      = false;
             isButtonDown  = false;
             tempContainer = FindContainer();
             if (JugeAssmeble(tempContainer))
             {
                 BeginAssmeble(tempContainer);
             }
             if (OnDragEnd != null)
             {
                 OnDragEnd.Invoke(this, containerBase);
             }
         }
     }
 }
Beispiel #4
0
        public void OnBeginDrag(PointerEventData eventData)
        {
            if (IsDraggable == false)
            {
                return;
            }

            SfxManager.Instance.Play(SfxType.UI_DragStart);

            OnDragBegin?.Invoke();

            selectedObject = this;
            startPos       = transform.position;
            IsDragging     = true;
        }
Beispiel #5
0
 static int SetDragBeginCallBack(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         ScrollRectExtend obj  = (ScrollRectExtend)ToLua.CheckObject <ScrollRectExtend>(L, 1);
         OnDragBegin      arg0 = (OnDragBegin)ToLua.CheckDelegate <OnDragBegin>(L, 2);
         obj.SetDragBeginCallBack(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #6
0
 protected void Invoke_OnDragBegin(object sender, DragArgs args)
 {
     OnDragBegin?.Invoke(sender, args);
 }
 public void OnBeginDrag(PointerEventData eventData)
 {
     SetDraggedPosition(eventData);
     OnDragBegin?.Invoke(this, new PointerEventArgs(eventData));
 }