Forum rules - please read before posting.

Unity UI Panels fail to re-size at runtime

Hi Chris and fellow AC Users,

I'm attempting (as I think many of us have) to create dynamically re-sizing "speech bubble" type boxes for my subtitles menu.

After a lot of wrangling, in the inspector I have a panel with an attached image element (my speech bubble sprite), a content size fitter and horizontal layout group. There's a regular text object as its child. When I type into the text field in the inspector, the speech bubble resizes horizontally and vertically to accommodate the text, paragraph breaks etc ...

Connected up as AC's subtitles menu, the bubble appears stretched horizontally to fit the text, but vertically as thin as it can go (i.e. none of the central part of the 9-slice is displayed) when the text is a single line, or stretched roughly one line if there are 2 or more lines of text - all the text is displayed slightly below the panel image, overflowing it.

I've been working on this for days, and the version in the inspector is pretty much exactly what I'm looking for, but I have no idea what AC is doing to produce this behaviour. Any ideas?

Cheers,

Martyn

Comments

  • So it all works as intended when AC isn't connected to it?

    Make sure that any RectTransform that's set to resize dynamically is not the "RectTransform boundary" assigned in the Menu's properties. Otherwise, AC will assume control over it's position, which may be interfering here.

    Can't think why else you'd get such behaviour. If you've moved these component to a child of the RectTransform boundary and it's still occuring, please share screenshots or steps so that I can attempt a recreation.

  • Thanks Chris - I'd suspected it was something like this, but ran into some problems using a UI panel as the RectTransform boundary for AC with a second panel inside for the speech bubble. An empty game object for the RectTransform did the trick, with the UI panel and text as children.

    For anyone else struggling with this (the topic seems to come up a lot here), I found this video really helpful: - be sure to read the comments if you're using a modern version of Unity.

    One final question - after being assigned a ConstantID by AC, is it normal/OK in the long term if the actual game object always disappears from the scene manager? As an example, of the two assigned fields in the subtitles menu, Unity UI Prefab remains, but after the RectTransform Boundary has been dragged in and assigned a permanent ID it vanishes immediately on running the game.

  • is it normal/OK in the long term if the actual game object always disappears from the scene manager?

    I assume you mean Menu Manager. But yes - assets will lose references to scene objects / prefabs, so ID numbers are there to retain the link.

  • edited April 2020

    [please delete]

  • I'm having a lot of trouble getting my Unity UI subtitles menu (the aforementioned speech bubbles) to appear where intended: Regardless of the menu's position type or the existence of a speech position child object on the NPC, it always appears at the central anchor (the blue circle) of the rect transform, wherever it's placed on the UI Canvas. Any ideas how or why AC's positioning is being hijacked?

  • AC will only ever control the "RectTransform boundary" - and that's only if you give it a dynamic Position type setting (e.g. Above Speaking Character, or if you're using the Auto Correct UI Dimensions component.

    If you don't wish for the speech bubbles to be positioned as a result of this, make sure it's not a child of the RectTransform boundary.

    As this is a visual problem, could you share some screenshots to illustrate what's going on? It would be best to see:

    • The issue as it occurs in-game
    • How things appear in the Scene window
    • The ordering of the UI's various elements in the Hierarchy
    • The Menu's properties in the Menu Manager
  • Solved it!

    As seems to be rather common for this kind of thing, it was simple but felt tangential to the core problem until I stumbled across the solution in the "try everything" phase.

    The UI canvas that contained the speech bubbles' render mode was set to Overlay, so it seems that whenever AC called for a bubble to be displayed, it was rendered in the centre of the screen where the game object was located on the canvas. Switching the render mode to the game camera made the bubbles display where the speech position child objects were in the scene.

    Thanks for your help and never-ending forum vigilance :)

  • edited May 2020

    I got the similar problem after update AC from 1.64 to 1.70 and now on 1.71.2
    My subtitle menu based on unity-ui sometimes flapping and i can't sorted it out.
    May be somebody could help with that?

    Small video

    Replic 2 initialy spawn on wrong position and then teleport to speech point
    This ActionList

    Menu settings

    Canvas settings

    I tried with default AC SubtitlesUI (only replace Text component with TMP-Text) and the same problem reproduced

  • edited May 2020

    What was the highest version of AC that didn't have this issue for you?

    Which object in the "SpeechBubbleCanvas" hierarchy is assigned as the Menu's "RectTransform boundary"?

    Try unchecking Update position? in the "Auto-correct UI Dimensions" component. If that makes no difference, what if you disable the whole component?

  • edited May 2020

    Hello Chris

    1.66.8 is last version where this menu works well
    After that we jumped to 1.70 and got this problem

    CustomOutline object is in RectTransform boundary field

    "Update position" unchecking and disabling "Auto-correct UI Dimensions" have no effect

  • I will attempt a reproduction, but is this also related to TMPro?

    If, in a duplicate project, you hook up a regular Text component instead, does the same thing occur?

  • It's reproducible without TMPro with default AC SubtitlesUI and my Prefab too.

    Here is small video with TMPro disabled and AC SubtitlesUI prefab

    And settings

  • I can recreate it in the sense that - for a single frame - the UI is in the wrong position. Is this what you're experiencing?

  • Yes. That's the problem. Just one single frame but very annoy pleyer's eye :(
    Is there chance or workaround to fix it?

  • Try this: open up Menu.cs, and find the line "Enable ();" around line 1871.

    Immediately underneath, insert the following:

    KickStarter.playerMenus.UpdateMenuPosition (this, KickStarter.playerInput.GetInvertedMouse (), true);
    

    Does that resolve it?

  • Yes. Thank you very much! The problem is solved.

    Only one small correction it's near EnableUI () not Enable ()

  • Quite right. I'll make the same change to the next release.

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.