- Home /
Redirect UI Events to non visible UI Hierarchy
I have two UI Hierarchies under separate root game objects as follows:
Hierarchy 1 (Canvas)
| - RawImage (Set with RenderTexture (As RT))
Hierarchy 2 (Camera - targetTexture set to RT)
| - Canvas (Camera space - set to camera above)
| - Image1 (would accept drag events)
| - Image2 (same as above)
| - InputField1
Hierarchy 1 is what is displayed on the screen, and because the camera has its targetTexture set to RT1, whatever is rendered by the camera in Hierarchy 2 is not visible on the display. That means Hierarchy 2 does not get events at all.
The issue is I'd like items in Hierarchy 2 to be interactable (the Images and InputFields) by the user, as they can see whatever the camera sees through RT on the RawImage.
The immediate solution is to attach an EventTrigger on the RawImage, subscribe to any events of interest, directly send the event data (BaseEventData) to a script attached to Hierarchy 2, which would implement those events of interest and manually handle any interactions with its items.
While that is a solution, I'm wondering if there's a more direct way of "piping" or "redirecting" any event from the RawImage to Hierarchy 2 to take advantage of Unity's built in event system.
Note that the Canvas in Hierarchy2 also has a GraphicRaycaster, if that helps.