Author Topic: Help with Anchors and Panels and Widgets oh my...  (Read 1562 times)

TommyT31

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
Help with Anchors and Panels and Widgets oh my...
« on: February 23, 2014, 09:36:29 PM »
Using the latest version of NGUI and have been spending the last month converting all my GUI elements up from version 2.x..

Ive noticed along the way there is a new anchoring system. I watched the video and attempted to use it but its just not making sense.

Let me elaborate.

Lets say I have a UIRoot with 3 Panels using the old UIAnchor scripts

Panel 1: Is anchored to the top and the UIAnchor script is attached to the UIPanel
Panel 2: Is anchored to the center and the UIAnchor script is attached to the UIPanel
Panel 3: Is anchored to the bottom and the UIAnchor script is attached to the UIPanel

There are of course then widgets nested under the respective UIPanel Game objects. This old sway seems to work great. What doesn't make sense to me anymore is that you can't seem to anchor the panels themselves using the new anchor system?? So it would seem you need to create an invisible type widget then nest all the objects under that. Although not knowing what your screen size will be makes creating that widget kind of a pain as you would need to stretch it? Perhaps I'm over thinking this but Im not sure if I need to now go through each and every widget with the new anchoring system and set its anchor to something else? I really don't want to do that. Id rather just set thier position on a UIPanel or some other game object the only set the panel as my UIPanel and Game objects under them objects don't get resized they just need to mostly be in the center of the screen at the size they are in the editor.

Am I over complicating this? How would a master center anchor work in the new layout system? Also is the UIAnchor script going to be phased out? Ive been going through converting all my unbutton message events over as part of this upgrade and perhaps if UIAnchor is staying I can still just use it? I don't want to be caught off base if we go through another update and have it no longer work. Id rather make these adjustments while Im going through every panel and object in all the scenes?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Help with Anchors and Panels and Widgets oh my...
« Reply #1 on: February 24, 2014, 02:11:20 PM »
You can't anchor panels that don't have a rectangle (read: clipping set).

A panel has no region. It simply collects and draws widgets. If you want to anchor panels, give them a clipping rect. Otherwise you can keep using the UIAnchor if you like.