Author Topic: [solved]Weird artifacts on 2D GUI with camera size of "1"  (Read 5207 times)

Steve Tack

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
[solved]Weird artifacts on 2D GUI with camera size of "1"
« on: March 31, 2013, 11:45:33 AM »
I was prototyping a UI element with NGUI yesterday and at first things were going great.  Then at some point, the entire UI became scrambled when running in the editor with Maximize on Play.  Now I don't know what that was all about, but eventually the UI showed up scrambled all the time.

I'm pretty new to Unity, though I do know how texture filtering works from my experience with doing XNA games, so I double checked that the atlas textures were set to point filtering/clamp/true color.  If I set them to another texture filtering setting, the "scrambled" appearance would go away, but the UI would look fuzzy, as expected.

So after about an hour of changing every setting I could find, I finally stumbled onto something.  If I set the UI camera's size to something like 1.01 or 1.001, everything goes back to pixel perfect.  But I don't really know what that means.  I have that hack in place, but ideally I'd like to know what's going on here.  Since I don't know what's going on, I don't know if this is quirky Unity behavior, something I'm doing wrong in NGUI, or what.

Here's what my prototype UI element looks like with the camera size set to 1:
http://www.stevetack.com/misc/NGUI_CameraSize_1.png

And here's with the camera size set to 1.001:
http://www.stevetack.com/misc/NGUI_CameraSize_1.001.png

Ideas?

I do have the purchased version of NGUI and I think it's the latest version (or close to it).

Thanks!

On a side note, playing around with Unity has been a BLAST so far, and having access to add-ons like NGUI is a far cry from what I'm used to in the XNA world.
« Last Edit: April 02, 2013, 04:23:29 AM by Nicki »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Weird artifacts on 2D GUI with camera size of "1"
« Reply #1 on: March 31, 2013, 03:07:27 PM »
Something is not pixel-perfect with your UI setup. Select the UIRoot and hit Alt+Shift+P. Also make sure the UIRoot is set to be pixel-perfect (from the drop-down list).

Steve Tack

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Weird artifacts on 2D GUI with camera size of "1"
« Reply #2 on: March 31, 2013, 07:55:50 PM »
Thanks for the reply!

I selected the top-most element of the UI that has UIRoot attached and pressed Alt-Shift-P, but that had no effect.  It's still weird looking if I change the camera size back to 1.  I did already have PixelPerfect for the Scaling Style.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Weird artifacts on 2D GUI with camera size of "1"
« Reply #3 on: March 31, 2013, 09:46:25 PM »
Do you have "half-pixel offset" checked on the UIAnchor? It must be checked for 2D UIs.

Steve Tack

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Weird artifacts on 2D GUI with camera size of "1"
« Reply #4 on: March 31, 2013, 10:18:07 PM »
Yes, I have that checked on both of my anchors.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Weird artifacts on 2D GUI with camera size of "1"
« Reply #5 on: March 31, 2013, 10:20:58 PM »
One last thing to check -- make sure your game window is actually the size it should be. Ie: if you set it to 1280x720, but your actual game window's size is smaller than that, you may encounter oddities.

Other than that, I don't know what's causing your issue. You'd be the first to encounter non pixel-perfection in a pixel-perfect UI.

Steve Tack

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Weird artifacts on 2D GUI with camera size of "1"
« Reply #6 on: April 01, 2013, 09:05:57 PM »
As I suspected, I think I was just doing something wrong with the NGUI settings.

I have the UI root, then camera -> panel -> two anchors.  Each anchor has a panel containing widgets and more panels.

For each anchor I had configured the "Ui Camera" property to the camera, but I had also set the "Panel Container" properties to the highest level panel without fully realizing what I was doing.  When I set Panel Container on both anchors back to None, the problem went away.  I had been using that setup for my other UI's without issue, but without fully understanding what I was doing I guess.

So I'm good now.  Clearly I'll need to read up on what those Container values are for before I use them!