I’ve been playing around with the new Unity UI and event system, and I was wondering how to make world canvasses and objects only react to events if they are within a certain distance.
I thought to make a custom raycaster, for both the canvas (GraphicRaycaster) and objects (PhysicsRaycaster). And this works, both need only minor changes to allow for it.
However, for canvasses this makes either the entire canvas or none of it interactable. Most of the time this isn’t that big a deal, only when they are very big, but luckily this doesn’t happen too often.
World objects have a different problem, all are interactable from an equal distance. It would be useful to be able to set a different interaction distance for each object. (Canvasses don’t have this problem because they all have their own raycaster, so the distance can be set for each.)
Is there a way to add such an ‘interaction distance’ to each object? Preferably as a separate component without having to re-implement the raycasters and objects such as button, as to make it compatible with other people’s plugins for the UI.
Note: I’m using C#.