Author Topic: Is UI Root necessary? or How to start an interface?  (Read 1748 times)

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Is UI Root necessary? or How to start an interface?
« on: July 02, 2014, 02:54:07 AM »
Hello.
Every time (or it seems to me) I add a new NGUI element to my scene, either by NGUI tab in the menu or by draggin a prefab a sprite is create which is named "UI Root" and contains a UI Root script.
I have many troubles with the autoscaling of that component.
In http://www.tasharen.com/forum/index.php?topic=6710 it's said "If you don't need the auto-scaling functionality of the UIRoot, you can get rid of this component altogether." so I'd like to remove that element.
But I can't completely remove the UI Root. And then I don't know how to proceed. My concern is:

1.- With a so weird autoscaling (let's say scaleX = 0.003333333) it's not easy to position my UI Camera, so: May I set the UI Root scale to (1, 1, 1)? Should I or may I remove the UIRoot script from the UI Root sprite to have remove that autoscale?
2.- Which is the structure of a NGUI user interface?, ie, how should I proceed? Do I need to have a main UI Root to place of my NGUI elements? I am quite a bit lost about how to start.

I have watched several of your video tutorials and it's clear how to make advanced things, but the initial basic setup is my main doubt.

Thank you.
Game developer on Casual Arena.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Is UI Root necessary? or How to start an interface?
« Reply #1 on: July 02, 2014, 05:56:16 AM »
All NGUI widgets need to be placed underneath a UIPanel in order for them to be drawn. UIRoot has a panel on it by default. When you drag something new into the scene, it looks for the UIRoot and places it underneath. If there is no UIRoot, it creates it. If you drag something into the hierarchy instead, it will remain where you left it (provided you left it underneath the panel).

The scale is simply 2 / Screen.height by default (or whatever size you give the UIRoot). 2 / 0.003333333 = 600, meaning your screen's height is 600 pixels tall. Why are you trying to position your UICamera? Everything that's a child of the UIRoot is in virtual pixels, so positioning it is simple: camera.localPosition = whatever. However again -- why position the UICamera? UICamera needs to remain stationary.

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Re: Is UI Root necessary? or How to start an interface?
« Reply #2 on: July 03, 2014, 12:09:58 PM »
I was just trying to use both my current gameObjects (without NGUI) with the new NGUI objects.
I think I know quite enough about "advanced" things with NGUI but I am having problems with the very basics, ie, with integrating NGUI in my current scene.

If I make it all just with NGUI, I do every thing perfect, but when using both NGUI elements and non-NGUI elements, problems come. Should I use NGUI for everything 2D? Should I consider NGUI like a whole framework and use only NGUI and not native Unity sprites?

Thank you and sorry for my weird questions.
Game developer on Casual Arena.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Is UI Root necessary? or How to start an interface?
« Reply #3 on: July 04, 2014, 01:29:32 PM »
If you want to mix NGUI with game elements, then I suggest making a 3D UI. To have 3D or in-game UI all you need is a UIPanel script on an object, and you can add child widgets to it. Just note that drag & drop was meant to work with a UIRoot (and thus ideally with a 2D UI).