How to get an UI element inside the screen if it gets out or the camera view?

Hello :slight_smile:

So I have this Text UI element that I position above my character head through code for dialogue
But sometimes my camera does close-ups in certain objects where the character’s head is no longer present, so the dialogue is not visible.
What’s the best way to force a element into the viewport if it gets out of the boundaries?

bump.
Any ideas, please?

Guys still have problems with this. Any help?

My method still has problems but it’s aimed at a similar problem