Author Topic: Unified Anchor resizing issue  (Read 4906 times)

par

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Unified Anchor resizing issue
« on: February 12, 2014, 06:39:01 PM »
I'll try and make this as quick and easy of an explanation as possible :)

Edit: I am using Unity 4.3.2f1 and NGUI 3.4.9

I created a UISprite that I will be using as a game mechanic.  Basically, I will be changing its scale on the fly via code.  When I created the UISprite I needed to resize it from the default (Snap) dimensions as it is too big for my purposes.  So I change its GameObject transform scale to 0.5, 0.5, 0.5.

Here you can see the UISprite placed exactly where I want it w/ regards to the UIRoot (UIRoot is of course the red outline).  This is prior to clicking anything on the Anchor UI.


Now, this image is right after I choose "Unified" for the anchor choice.


As you can see, it automatically modified the size and position of the sprite as soon as I chose "Unified" for the anchor type.

At this point I am in positioning hell because I need to mess w/ those 4 anchor values to get it back to its correct size and its correct position.

To make it worse, I will be adding more UISprites that completely depend on the very center of this UISprite.

Is there any easier way to do this?

Thank you!

PAR




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unified Anchor resizing issue
« Reply #1 on: February 13, 2014, 12:32:12 AM »
Change the pivot to top-left. That should help a bit. The anchoring system is ideal for things that aren't scaled though, keep that in mind. I would also advise you to make an invisible widget (ALT+SHIFT+W), and anchor that instead. Make your scaled sprite a child of the anchored widget (and don't anchor the sprite).

par

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Unified Anchor resizing issue
« Reply #2 on: February 13, 2014, 08:35:01 PM »
Hey Mook, thanks for the reply.

Yes, I found out just a bit ago that if I leave the GameObject transform alone when placing the Sprite and use the Widget dimensions for scaling prior to runtime that now the anchoring options work very smoothly.  I didn't see the mention of "keeping the GameObject scaling alone" anywhere in the documentation so that might be a point of confusion to some (certainly was my problem).  Now, if I kept to that rule, things rock.

Thanks much!

PAR