Author Topic: Changing scene makes the GUI all blurry  (Read 5796 times)

Erhune

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Changing scene makes the GUI all blurry
« on: January 22, 2014, 01:55:53 PM »
I have 2 scenes, each with their own GUI. They are supposed to run in 1280x720 only, are setup with a fixed-size UIRoot of 720, my Game view in Unity is also setup to display 1280x720, and is not resized. When I load any of the scenes in the editor, I have a crisp GUI, no problem.

But if I load one, then Application.LoadLevel(theOther), I end up with the GUI of theOther scene very blurry. All the sprites seem to be 1 pixel smaller in every direction, I can see joints between sprites that are positionned adjacently. The weird thing is all transforms are correct (position, scales, widget sizes...), the UIRoot scale is correct, the camera settings are exactly the same that if I just loaded the scene manually...

I noticed this by upgrading from 3.0.6 to 3.0.8, and tried again with 3.0.9f4 with the same results...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing scene makes the GUI all blurry
« Reply #1 on: January 23, 2014, 06:42:05 AM »
If your game window is actually 1280x720, and UIRoot is fixed size on 720, then it's the same as having UIRoot set to Pixel Perfect, and likewise should certainly yield the same results. I see no reason why there would be any difference. You're not scaling anything from a size of zero, are you?

P.S. Don't use UIAnchors anymore.

Erhune

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Changing scene makes the GUI all blurry
« Reply #2 on: January 23, 2014, 08:27:54 AM »
I don't do any scaling at all. Only the UIRoot in the hierarchy has a non-1 scale.

I tried with UIAnchors or without, didn't make any difference.

What makes a difference though is translating my Panels by 0.5 in both X and Y. That restores the whole crispness of the GUI.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing scene makes the GUI all blurry
« Reply #3 on: January 24, 2014, 07:41:35 AM »
Go through your UI and make sure that nothing has an offset of 0.5. If you've ever had a center-based UIAnchor, then you probably do. In prior versions UIAnchor used to offset by 0.5, now it doesn't.

Erhune

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Changing scene makes the GUI all blurry
« Reply #4 on: January 29, 2014, 11:55:38 AM »
Nothing had 0.5 offsets anywhere, unfortunately.

After much trial & error, I put back the old code in UIAnchor to add the 0.5 offset, but *only* when I switch scenes, and it fixed my problem. But I must admit I'm not very satisfied with the solution, which is not very elegant code-wise.

I tried to use the new anchor system to anchor panels on the side of the screen, but I must admit that I couldn't get it working, even in very simple setups (I'm using 3.0.9f7). Here is what I tried to anchor on the top left corner of the screen. Using the following hierarchy:

UIRoot
   UICamera
   UIPanel
      My widgets

My first problem is clipping on the panel. I do not need clipping, but I cannot anchor if I don't have some. So let's say I use alpha clipping, with a 300x300 rect. I setup an advanced anchor on the panel, set the UICamera as the left anchor + 0, the UICamera as the top anchor + 0, and leave both right and bottom anchors to None. When I hit play, the widgets start on the top left corner, but then move to the center of the screen. Same effect if I use the UIRoot as reference instead of the UICamera. Any idea what I am doing wrong?

Also, small suggestion: adding a small button to reset the anchor reference to None would help tremendously (it's quite time-consuming to click the object selector, scroll all the way up, and finally choose None).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing scene makes the GUI all blurry
« Reply #5 on: January 29, 2014, 10:53:34 PM »
A panel has no rectangle. A panel is just something that collects and draws widgets.

Since it has no rectangle, there is nothing to anchor.

If you turn the panel into a scroll view by giving it a clipping rect, then you can anchor that rect -- but you can never truly anchor a panel because there is nothing to anchor. Not sure why you are even trying it. Anchor the widget instead.

P.S. And make sure the game window is not of odd dimensions like 1207x500. That too will make it blurry.