It works OK, but I couldn’t find another way to extract the gameobject from a UI Pointer event.
This flowchart is attached to an empty gameobject and (among other stuff) highlights whatever object is clicked by assigning a different material.
There is an included Event that you can use for this, called “Mouse Pick” and found under “Events/Input” subcategory.
The Flow output is called whenever the player clicks the mouse on some collider in the scene (you can also set a LayerMask in the node’s inspector) and the Pick Info output is a RaycastHit type containing the info.
BTW, i believe i found a bug in Debug.DrawLine and Debug.DrawRay
I couldn’t get them to draw lines/rays in the editor, while doing it through a C# script works fine. There’s a chance I might be doing something wrong, but I thought I’d let you know.