Forum rules - please read before posting.

How are Unity UI menus placed in relation to a speech placement child object?

Hello AC community -

I noticed that the last update fixed a bug related to this topic, but after updating, I'm still having all kinds of strange subtitle positioning when my menus are Unity UI, set to "above speaking character" and a speech placement child is added to the character. There are two main issues:

  1. I can't seem to correlate the speech child position with where the subtitles menu appears in-game, often, to get the position I want, the speech child has to be positioned far from the character and seems to bear no real relation to where the subtitles are generated. What anchor point/pivot does AC use to position the rect transform, and where should it be to keep it close to the child position position in the scene view?
  2. When I check the scene view at runtime, the speech child has often moved - particularly if the character it's attached to has moved during play.

There are a number of other forum threads on similar topics, but most of them don't get resolved, so I'd appreciate any help that's available!

Cheers.

Martyn

Comments

    1. How the menu is positioned will depend on the Canvas settings, the Menu's properties, and whether or not you're enforcing an aspect ratio in the Settings Manager. Let's see screenshots of all - as well as examples of how it appears in-game - to understand the situation.

    2. It should move with the character. Where is it moving to?

  • Preparing some screens for point 1; regarding point 2, the speech child does move with the character, but while it is quite far from the character in the prefab, once they complete their walk it is right next to them, as if they pushed it along?

  • "How the menu is positioned will depend on:

    the Canvas settings,

    [img]https://i.imgur.com/6H5Pa0t.png[/img]

    the Menu's properties,

    [img]https://i.imgur.com/uWvobmV.png[/img]

    and whether or not you're enforcing an aspect ratio in the Settings Manager.

    [img]https://i.imgur.com/eE45NsE.png[/img]

    Let's see screenshots of all - as well as examples of how it appears in-game"

    This is Steve in the inspector (please excuse his blank expression, he's new to animation blend layers) with the position of his speech placement child:

    [img]https://i.imgur.com/WXoDO2Q.png[/img]

    And him in game - the speech appears really high up!

    [img]https://i.imgur.com/30AhQjy.png[/img]

    He is scaled a little via a sorting map - I noticed at the weekend that scaling characters with sorting maps seems to monkey with the placement of their "feet" circle colliders, moving them up to around the ankles, so maybe that's involved?

  • Thanks for the screenshots, but they're too cropped. What is the rest of the Canvas Inspector (the prefab, not the component), and what is the Menu's "RectTransform boundary" linked to?

    It would be best to also see how this RectTransform boundary appears in the Scene window itself. This is what will be repositioned (by controlling its centre-point) at runtime - but if you have Always fit within screen? checked then it will also limit position by the RectTransform's edges.

    This could be caused by either the menu, or the character, or both. We'll need to isolate the two to work out which.

    First drop the 2D Demo's Player prefab, Brain2D, into the scene. He'll override your own, provided your own isn't also in the scene file.

    Do you still get the same issue? If so, copy/paste the 2D Demo's Subtitles menu into your own Menu Manager. That can be gotten by assigning the Menu Manager's asset field to 2DDemo_MenuManager at the top of the Manager.

    Is this new menu appearing in the correct place? If so, remove Brain2D from the scene to rely once again on your own. Does this new menu then appear correctly above your own Player?

    but while it is quite far from the character in the prefab, once they complete their walk it is right next to them, as if they pushed it along?

    I'm afraid I don't really follow. Can you rephrase or illustrate this?

  • So, Brain (who is comically small in our scene :smiley: ) gets my menu positioned just above him, as I would expect. Adding the 2DDemo_MenuManager puts your subs menu pretty much slap-bang on my characters speech placement child. By my rudimentary maths that means the problem is with my menu.

    Oh, one other thing - unticking** Always fit within screen?** makes the placement about 75% better.

    Here's the scene view of the speech bubble (Steve's one):

    https://imgur.com/nLYJGfQ

    And the inspector of the canvas, in two parts:

    https://imgur.com/wGjrjm9

    https://imgur.com/KjOTBqv

    The linked rect transform is Bubble Boundary which is an empty game object that contains the panel, dummy text (that controls the size of the panel re: this thread https://www.adventurecreator.org/forum/discussion/10378/subtitle-boxes-appear-at-full-size-then-fill-with-text#latest ) and the real text box.

    At the moment my feeling is that the weird placements I'm getting are possibly in relation to using Screen Space - Overlay, which might explain why they often appear right in the center of the screen. Not sure how Screen Space Camera works with ACs camera management system though.

    Finally, since my bubbles dynamically size with the text in them, I think it would help if AC could position them based on the bubble tail, or the bottom left/right corner of the bubble. Is that possible without invasive scripting surgery?

    (As ever, thanks for your help with all this, and I hope other forum posters are learning as much from my questions as I do from theirs)

  • AC should cater for all the "Canvas Scaler" options, but is there a reason you've entered such specific values for the "Reference Resolution" field?

    Especially given that you're relying on custom scripts, I think it'll be best for me to just have a play with this myself - can you PM me the prefab, your Menu Manager, and the script as a .unitypackage file?

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.