private void Update(MouseState state, Vector3 rawMousePos) { ResizeTypes type; Vector3 resizePos = Panel.InverseTransformPoint(rawMousePos); bool inResizePos = !UIManager.NavBarRect.rect.Contains(UIManager.NavBarRect.InverseTransformPoint(rawMousePos)) && MouseInResizeArea(resizePos); Vector3 dragPos = DragableArea.InverseTransformPoint(rawMousePos); bool inDragPos = DragableArea.rect.Contains(dragPos); if (WasHoveringResize && s_resizeCursorObj) { UpdateHoverImagePos(); } switch (state) { case MouseState.Down: if (inDragPos || inResizePos) { UIManager.SetPanelActive(Panel, true); } if (inDragPos) { if (AllowDragAndResize) { OnBeginDrag(); } handledInstanceThisFrame = true; return; } else if (inResizePos) { type = GetResizeType(resizePos); if (type != ResizeTypes.NONE) { OnBeginResize(type); } handledInstanceThisFrame = true; } break; case MouseState.Held: if (WasDragging) { OnDrag(); handledInstanceThisFrame = true; } else if (WasResizing) { OnResize(); handledInstanceThisFrame = true; } break; case MouseState.NotPressed: if (AllowDragAndResize && inDragPos) { if (WasDragging) { OnEndDrag(); } if (WasHoveringResize) { OnHoverResizeEnd(); } handledInstanceThisFrame = true; } else if (inResizePos || WasResizing) { if (WasResizing) { OnEndResize(); } type = GetResizeType(resizePos); if (type != ResizeTypes.NONE) { OnHoverResize(type); } else if (WasHoveringResize) { OnHoverResizeEnd(); } handledInstanceThisFrame = true; } else if (WasHoveringResize) { OnHoverResizeEnd(); } break; } return; }
public void Update() { Vector3 rawMousePos = InputManager.MousePosition; ResizeTypes type; Vector3 resizePos = Panel.InverseTransformPoint(rawMousePos); Vector3 dragPos = DragableArea.InverseTransformPoint(rawMousePos); bool inDragPos = DragableArea.rect.Contains(dragPos); if (WasHoveringResize && s_resizeCursorObj) { UpdateHoverImagePos(); } // If Mouse pressed this frame if (InputManager.GetMouseButtonDown(0)) { if (inDragPos) { OnBeginDrag(); return; } else if (MouseInResizeArea(resizePos)) { type = GetResizeType(resizePos); if (type != ResizeTypes.NONE) { OnBeginResize(type); } } } // If mouse still pressed from last frame else if (InputManager.GetMouseButton(0)) { if (WasDragging) { OnDrag(); } else if (WasResizing) { OnResize(); } } // If mouse not pressed else { if (WasDragging) { OnEndDrag(); } else if (WasResizing) { OnEndResize(); } else if (!inDragPos && MouseInResizeArea(resizePos) && (type = GetResizeType(resizePos)) != ResizeTypes.NONE) { OnHoverResize(type); } else if (WasHoveringResize) { OnHoverResizeEnd(); } } return; }