void Update() { // Check if grab key is pressed if (HighLogic.LoadedSceneIsFlight) { if (Input.GetKeyDown(grabKey.ToLower())) { EnableGrabMode(); } if (Input.GetKeyUp(grabKey.ToLower())) { DisableGrabMode(); } } // Check if attach/detach key is pressed if (HighLogic.LoadedSceneIsFlight) { if (Input.GetKeyDown(attachKey.ToLower())) { EnableAttachMode(); } if (Input.GetKeyUp(attachKey.ToLower())) { DisableAttachMode(); } } // Drag editor parts if (HighLogic.LoadedSceneIsEditor) { if (Input.GetMouseButtonDown(0)) { if (!UIManager.instance.DidPointerHitUI(0) && InputLockManager.IsUnlocked(ControlTypes.EDITOR_PAD_PICK_PLACE)) { Part part = KIS_Shared.GetPartUnderCursor(); if (part) { OnMouseGrabPartClick(part); } } } } // On drag released if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) { if (draggedPart && Input.GetMouseButtonUp(0)) { OnDragReleased(); } } }
void Update() { if (partDetectionActive) { Part part = KIS_Shared.GetPartUnderCursor(); // OnMouseDown if (Input.GetMouseButtonDown(0)) { if (part) { if (delegateOnMousePartClick != null) { delegateOnMousePartClick(part); } } } // OnMouseOver if (part) { if (delegateOnMouseHoverPart != null) { delegateOnMouseHoverPart(part); } } if (part) { // OnMouseEnter if (part != hoveredPart) { if (hoveredPart) { if (delegateOnMouseExitPart != null) { delegateOnMouseExitPart(hoveredPart); } } if (delegateOnMouseEnterPart != null) { delegateOnMouseEnterPart(part); } hoveredPart = part; } } else { // OnMouseExit if (part != hoveredPart) { if (delegateOnMouseExitPart != null) { delegateOnMouseExitPart(hoveredPart); } hoveredPart = null; } } } if (HighLogic.LoadedSceneIsEditor) { if (Input.GetMouseButtonDown(0)) { if (!UIManager.instance.DidPointerHitUI(0) && InputLockManager.IsUnlocked(ControlTypes.EDITOR_PAD_PICK_PLACE)) { Part part = KIS_Shared.GetPartUnderCursor(); if (part) { if (delegateOnMousePartClick != null) { delegateOnMousePartClick(part); } } } } } }