Text scales differently in player than in editor?

Hello all, i have a test scene with some text, the canvas is set to scale with screen size, and i have a pixel perfect camera. Something odd happened while i was testing out my game. As you can see, the text scales differently when running in the player, than in the editor. It’s not incredibly major, but i feel as though depending on the context, it could cause problems and get out of hand.

  1. Scene view
    https://i.gyazo.com/c3df89188ecc53d387964ab96ff161f8.png

  2. Game view
    https://i.gyazo.com/4c208293c7e99dac110fb07a16124c30.png

  3. Built game
    https://i.gyazo.com/41bd35104582a8fe5a27c18a0243cee2.png

Could be a font issue maybe? Maybe a fallback font is being used in the build? Are you testing on the same device as you’re editing on?

Yes

The canvas is set to scale with screen size, and it only seems to happen with pixel perfect camera enabled. Could those have anything to do with it? As can be seen here, when the pixel perfect camera is disabled, the build looks the same as in-editor

bump

If it helps any, my monitor’s resolution is 1920x1080 and the PP camera’s reference resolution is 320 by 180. I feel like that has something to do with it, i just dont know how, why, or what to do to fix that.

You might get some more responses to this over in the UI forum: Unity Engine - Unity Discussions

i was about to, actually, but then i looked closer and realized its not just text, the entire camera behaves this way

  1. scene view
    https://i.gyazo.com/48953b1fc414a87f38b438635718372d.png

  2. game view
    https://i.gyazo.com/4e554b72c1a914947e39583b3dc42ca2.png

  3. built
    https://i.gyazo.com/41bd35104582a8fe5a27c18a0243cee2.png

bump

Hm, it seems to be as though the game view aligns more with the inner, dotted line box, while the actual build aligns more with the outer, solid box.

  1. scene view
    https://i.gyazo.com/5af1ae76c24e59475a20ff9f4087caa7.png

  2. game view
    https://i.gyazo.com/8edb13344fe1654d2f8a5241ba2ec69e.png

  3. built
    https://i.gyazo.com/3e7030395055b441a981dac607ccf3c1.png

bump

You don’t need to constantly bump the thread.
Are you using the regular Text component or TextMeshProUGUI?

Regular text component, though as noted above, its not just text, it appears to be the entire camera. Particularly the pixel perfect camera. So i suspect it has something to do with that.
It’s piqued my curiosity, not only as to why the camera is behaving this way, but also as to why the text scales differently despite the aspect ratio being the same in all cases

TextMeshPro is sharper than the regular text component due to using Signed Distance Field (SDF).

Do you really need pixel perfect? If not disable pixel perfect.
Replace Text component with Text Mesh Pro you’ll probably achieve a better result.

Yes, i would like to keep pixel perfect because it keeps the sprite art looking nice at any resolution.

I noticed that when it gets resized in game view, it seems to match the outer, solid green box of the pixel perfect camera, so in editor i resized the white camera box to match:


so that issue is gone, however, the build still seems to resize the camera to match the inner, dotted line box. I thought this might have something to do with me checking “upscale render texture”, because i recall that works by rendering the camera at the reference resolution size, then upscaling. However disabled “upscale render texture”, still leaves the camera resized as seen here.

I’m completely out of ideas. ¯_(ツ)_/¯

Yeah, i’m at the end of my rope here. I’ve read as much as i can about the pixel perfect camera and nothing anywhere explains this behavior. Good thing i didnt get too far with this game, otherwise i’d be mad. Word of advice for any other devs reading this thread, always test your game by building it once in a while. Unity’s editor window can’t be trusted to reflect what it will actually look like :slight_smile:

I’m fairly sure that the difference you’re seeing is the difference in resolution.
The handles you’ve used to align the camera is the FoV. You have to account for different screen resolutions / aspect ratios, or just force one (which is mostly unwanted behaviour).
In the editor you can change resolutions of the game view. Try changing it up to Free Aspect and take out the Game window. Resize it to see what happens with your view.

The text breaks, but no amount of resizing the window ever makes the camera zoom in the way it does in a build.

I’m not sure what a Pixel Perfect Camera is (there are pixel perfect canvases, are you referring to that?). I’d guess something from the Asset store? Do you see the same behavior with a plain old Unity camera?