Author Topic: [nGUI]Some Problems with relative Size  (Read 11176 times)

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
[nGUI]Some Problems with relative Size
« on: December 24, 2012, 09:44:29 AM »
Hey there,

i bought nGUI recently and fooled a little bit around in a new test scene. Now i want to built the GUI in my existing iPhone-project.
I have to cameras (a Main Camera and Parallax Camera for the Scrolling-Effect) with both a size of 3.2 (in order to make my other Sprites pixel-perfect).

Now i just made another Layer called GUI for the UICamera when i made a "New UI" via the nGUI-Menu. The size of the camera is 1, which looked fine to me at first, but then i started making my Interace-Objects.

First i made an TextureAtlas with all the .PSD Files.
(At this point i have to say: i really like the workflow of nGUI! I didn't have to look in the documentation and figured the most functions out by the nice structure of this plugin. That is great!)

And then i'll start adding the stuff i need, and now i got some problems with the Size and i can't handle it properly:

So here is my UIRoot-Object with the Anchor, the Panel, and an UISprite in the Scene and Game-View:



As you see, in the Game-View it's looking how i want it, but nGUI works the other way :D
It's about the Scene-View, and so i get this, when i play it:




I don't know which settings to manipulate and would be very grateful for some help, because i really really like the workflow of that plugin and want to work properly with it.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [nGUI]Some Problems with relative Size
« Reply #1 on: December 24, 2012, 11:18:25 AM »
Ok, first thing to note is that your game view is not the size you think it is. You have it set to 960x640, but your actual window is smaller than that. If you really want it to be pixel-perfect, you need to undock your game window and have it actually reach the size it should be. You can open up the "Stats" window to see its real size.

Second thing to note is that the book in your first screenshot is very blurry -- meaning it's not pixel-perfect. In your second screenshot it's crisp, meaning it actually is pixel-perfect.

Lastly, in order to attach something to the bottom of the screen like you are trying to do, you need to use a UIAnchor. Watch this video, it may help you understand some things: http://www.youtube.com/watch?v=XAeRXckXMMw

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: [nGUI]Some Problems with relative Size
« Reply #2 on: December 24, 2012, 02:43:42 PM »
Quote
Ok, first thing to note is that your game view is not the size you think it is. You have it set to 960x640, but your actual window is smaller than that.

Yes i know that! I have "Maximize on Play" selected, so, if I press "Play" it will give me the size/resolution i want to (and that's also how it looks on the Device)

But thank you for the clarification :)

I'll look at the video and will post if I succeded, thanks for the support ArenMook!

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: [nGUI]Some Problems with relative Size
« Reply #3 on: December 24, 2012, 06:06:42 PM »
So, made some progress. I looked in the Examples and studied the structure, and didn't understand everything :D
But, i think my mistake is, that i am trying to built the UI relative to the GameView.

So, this is my 960x640 Game View:



And as you see i marked the parts red where i wanted to have my UI-Elements. So i thought i have to place the UI-Elements incl. the UI-Root-Object like here (Scene View) and have to make the UI-Camera as big as the the other cameras (3.2) :



This gave me some headaches regarding the Scale of the Sprites. Then it came to my mind, that this is actually a seperate camera...
So i can place the UI-Root with its objects (Camera, Planes etc.) wherever i want them to. So did i, and did this:



Made a simple new UI and added these Sprites there and moved them slightly below the purple box (this is the Ui-Root Object, i guess? ) around till i got it like i wanted in the Game-View:



Now it looks fine in the Game-View and much better on the actual device.

Is this the right way to handle it? Or will be there some problems regarding future use of the UI-Elements?



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [nGUI]Some Problems with relative Size
« Reply #4 on: December 24, 2012, 06:46:05 PM »
It's fine, but I am a bit unclear why the purple box doesn't match the screen size for you. Also keep in mind you should use UIAnchor to anchor a game object to the bottom of the screen, then make your buttons and book a child of that object. Be sure to use Alt+Shift+N to add the game object, as a child of the UI hierarchy (child of the camera for example) so that it sets the layer properly.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: [nGUI]Some Problems with relative Size
« Reply #5 on: December 26, 2012, 07:55:21 AM »
Well my Structure is like this:



Is it better to make for each Objects an own Anchor?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [nGUI]Some Problems with relative Size
« Reply #6 on: December 26, 2012, 11:05:54 AM »
No, the way you have it is fine, assuming that anchor is set to anchor to the bottom of the screen.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: [nGUI]Some Problems with relative Size
« Reply #7 on: December 26, 2012, 11:45:33 AM »
Yes, it is :)

Thank you for the good/nice support!

soraphol

  • Guest
Re: [nGUI]Some Problems with relative Size
« Reply #8 on: January 28, 2013, 05:31:33 AM »
I just start using NGUI and has the exact same problem. The UI somehow will start shrinking after I pressed "Play". No sure that this is the proper way to fix the problem or not; however, I found out that by setting 'scaling style' to "FixedSize" at UI Root (2D), the UI size at edittime and runtime will have an exact same size. Hope that this helps.