private void On_CameraRayCaster_OnRayCastableExit(IRayCastable rayCastable) { BAnchor bAnchor = (BAnchor)rayCastable; if (bAnchor && bAnchor == raycastedBAnchor) { raycastedBAnchor = null; if (IS_NOT_NULL(bButton)) { bButton.DisableButton(); } } }
private void On_CameraRayCaster_OnRayCastableEnter(IRayCastable rayCastable) { BAnchor bAnchor = (BAnchor)rayCastable; if (bAnchor) { raycastedBAnchor = bAnchor; if (IS_NOT_NULL(bButton)) { bButton.EnableButton(); } } }
// Check if mouse cursor is over interactable object private bool ChangeCursorOnUI() { // On release left-click, set drag to false if (Input.GetMouseButtonUp(0)) { isDraggingUI = false; } if (isDraggingUI) { return(true); } // Raycast under mouse curse and see if top item is interactable (can be extended to get array and sort) RaycastHit2D hit = Physics2D.Raycast(Input.mousePosition, Vector2.zero, Mathf.Infinity, grabbableLayers); if (hit.collider != null) { IRayCastable rayCastable = hit.collider.GetComponent <IRayCastable>(); if (rayCastable != null) { // On left-click, set drag to true and change cursor if (Input.GetMouseButtonDown(0)) { isDraggingUI = true; isHoveringUI = false; SetCursor(CursorType.Grab); return(true); } else if (!isHoveringUI) { isHoveringUI = true; SetCursor(rayCastable.GetCursorType()); } return(true); } } isHoveringUI = false; SetCursor(CursorType.None); return(false); }
private void ProcessRaycastHit(RaycastHit hit) { IRayCastable rayCastable = BUtils.GetComponentInHierarchy <IRayCastable>(hit.transform.gameObject, true); if (rayCastable != null) { // Enter if (rayCastablesMap.ContainsKey(rayCastable) == false) { rayCastable.OnRayHoverEnter(); rayCastablesMap.Add(rayCastable, true); InvokeEventIfBound(OnRayCastableEnter, rayCastable); } // Stay else if (rayCastablesMap.ContainsKey(rayCastable) == true && rayCastablesMap[rayCastable] == false) { rayCastablesMap[rayCastable] = true; InvokeEventIfBound(OnRayCastableStay, rayCastable); } } }