Forum rules - please read before posting.

Subtitles do not show above player's head with Unity UI

edited July 2024 in Technical Q&A

I have created a Unity UI prefab speech bubble to place above my player's head when speaking with Background Only dialogue.

I have set Position Type to Above Player, but it stays middle of screen instead.

Here is a video where you can see and example and my settings:

https://imgur.com/a/qr59ln9

Comments

  • Unity UI-based Menus are repositioned by affecting the assigned "RectTransform boundary" object. You'll need to assign an appropriate object (either TextBox going by your video, or an intermediate empty object between that and the Canvas root) into this field.

  • Great! That seems to work. However it goes directly above my player's head, centered no matter what. Is there any way within AC to add on offset to the positioning, or do I need to add empty space UI prefab itself?

  • Ideally I would offset it upwards and to the right so it looks like a speech bubble ought to.

  • Add an intermediate empty object as mentioned above - that way, you can control the position of the speech bubble independently of the RectTransform boundary.

    Also worth mentioning: a ready-made speech bubble UI template is available on the Downloads page.

  • I've gotten it above my head, but even with always fit within screen it seems to go offscrene no problem like in the video

  • The RectTransform boundary will be used as a reference for whether or not the Menu is off-screen. You'll need to make sure that this encompasses the space that the visible speech bubble takes up.

    Alternatively, as yours is a 2D game, you can assign a Speech placement child Transform in the Player's Inspector to set the exact position you want to place the Menu at. This can be a child object positioned slightly to the right of the character's head.

  • For whatever reason, even with everything set to Play in background, having my speech bubble pop up is blocking me from clicking on other UI buttons. For example if I start a dialogue played in the background, which triggers my speech bubbles, I can continue to move around and see hotspots but I cannot click the inventory UI button in the corner, but I can open it via the keyboard input.

    This does not happen with other UI, for example if my inventory is open I can still click the inventory button to then close it.

    https://imgur.com/a/IBD3URO

  • What's the shape/size of the assigned RectTransform boundary? Clicks will be blocked if they land on it - even if its invisible to the user.

    You should be able to avoid this behaviour, though, by checking Ignore input? in the Menu's properties.

  • The rect transform boundary isn't large enough to reach the bottom corner. I've checked ignore input, but the behavior remains the same.

  • View the bottom of the Inspector of your EventSystem object, listed in the Hierarchy at runtime. This will show the currently-selected UI object - what does it show at the time?

  • Whoops looks like it wasn't the rect transform boundary, but the speech bubble's UI canvas that still was blocking input/raycast. Thanks for all the help!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.