UI changing size with screen

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

UI changing size with screen

Post by lostmushroom »

Hey, I'm having a couple of UI problems.

The first is that the UI changes size and position depending on the size of the screen. This means that narration text is showing up in the wrong place. Examples below.
screen 1.JPG
screen 1.JPG (31.44 KiB) Viewed 3190 times
screen 2.JPG
screen 2.JPG (37.48 KiB) Viewed 3190 times
I'd like the text to always be in the same place regardless of screen size. Aiming for something closer to the first image.

I'm sure this is probably just an anchoring thing but I'm kind of an idiot when it comes to UI so I'd appreciate a nudge in the right direction :)

Secondly, I'm not sure how to hide NPC text when the player is making a choice. Right now, the NPC text stays in place behind the player choices. I'd like to make it disappear as soon as it switches to player dialogue.

Thanks :)
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI changing size with screen

Post by Tony Li »

Hi,

Is the narration text in a Screen Space canvas or a World Space canvas?

If it's a Screen Space canvas, you have two options:

1. Place it exactly where you want it, and add a Canvas Scaler to the canvas. Play around with the Width <--> Height slider. The Canvas Scaler will scale the UI to a specific resolution. For example, if you set the Canvas Scaler's reference resolution to 1600x1200 and the player's screen is 800x600, then the narration text will be shown at half its normal size.

2. Or, to keep the text the same size regardless of resolution, set the anchor to the bottom center. You'll probably also want to set the pivot to X=0.5, Y=0.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: UI changing size with screen

Post by lostmushroom »

It's screen space. It's the Basic Standard UI.

I added a Canvas Scaler, but it only has a warning message saying Non-root Canvases will not be scaled.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI changing size with screen

Post by Tony Li »

That means it's nested inside another canvas. Follow up the hierarchy until you find the highest canvas that it's under, and try adding the Canvas Scaler to that canvas instead.

Or, if you want the text to stay the same size regardless of resolution, adjust the anchor as in #2 above.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: UI changing size with screen

Post by lostmushroom »

The highest canvas in Basic Standard Dialogue UI seems to be Canvas(Environment), but it's greyed out and I'm unable to edit it.

I think the anchor point solution is what I need, but I guess that would have to apply to the "top" canvas as well? Is there a way to make it editable?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI changing size with screen

Post by Tony Li »

lostmushroom wrote: Sat Aug 10, 2019 4:40 pmThe highest canvas in Basic Standard Dialogue UI seems to be Canvas(Environment), but it's greyed out and I'm unable to edit it.
That means you're editing the Basic Standard Dialogue UI prefab, so the Unity editor has created a temporary canvas named Canvas(Environment) to be able to show it in the Scene view.

Instead, inspect the Dialogue Manager in your scene and a Canvas Scaler to the Dialogue Manager's Canvas.
lostmushroom wrote: Sat Aug 10, 2019 4:40 pmI think the anchor point solution is what I need, but I guess that would have to apply to the "top" canvas as well? Is there a way to make it editable?
Change the anchor of the subtitle panel, not the canvas. However, I recommend that you make a copy of the prefab, customize the copy and assign it to the Dialogue Manager's UI, and move it to a different folder. This way you won't lose your customizations if you update the Dialogue System.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: UI changing size with screen

Post by lostmushroom »

Ok cool, thanks. I'm getting a little closer :D

Is there a way to hide NPC text when player choices are being displayed?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI changing size with screen

Post by Tony Li »

Sorry, I forgot to answer that part. Yes. Inspect the NPC Subtitle Panel, and change the Visibility dropdown to Only During Content.
Post Reply