Author Topic: Offset anchors by position  (Read 3029 times)

Decco

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 20
    • View Profile
Offset anchors by position
« on: September 17, 2014, 09:59:25 AM »
Hi,

When you check the option "Offset anchors by position" on a panel, if the UIRoot is not at (0,0,0), the underlaying anchored widget is offset by the UIRoot position + the UIPanel position.
It should be only offsetted by the Panel position, I think.

In the screenshot, UIRoot is set to (0,10,0), UICamera to (0,0,0), UIPanel to (0,0,0) and the sprite is anchored to the top left corner of the Panel.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Offset anchors by position
« Reply #1 on: September 17, 2014, 01:00:12 PM »
This happens because you're moving the UIRoot, which has a panel on it... and the UICamera is its child. Since you are not using clipped panels, anchoring a widget to the root effectively anchors it to the camera. However the camera is moved, and the panel is offset by position...

Long story short, move the camera outside the UIRoot and it will work as expected. Camera shouldn't be moving. The "Offset" feature was not meant to be used on the UIRoot.

Decco

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 20
    • View Profile
Re: Offset anchors by position
« Reply #2 on: September 18, 2014, 03:35:47 AM »
Hi,

Sorry but there is no Panel on the UIRoot, I removed it. Instead I have added a panel as a child of the camera (you can see it on the screenshot).
I'm doing that because I need multiple panel under the same camera.
Each panel will manage one window. That's the right way to do it, right ?

So, the sprite under the panel, is anchored to its panel, not to the camera or the UIRoot.
If I check the option "Offset anchors by position", on that panel, it allow me to move the panel under the camera with the anchored sprite, right ? (Else the sprite doesn't move if not checked) It's working well to make some animation, for exemple.

But now, if you just move the UIRoot out of (0,0,0), because you setup the GUI outside of the game assets (it's easier to view when there is no other assets in front of the camera),
the offset is now broken..

Am I doing anything wrong ?
« Last Edit: September 18, 2014, 03:44:37 AM by Decco »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Offset anchors by position
« Reply #3 on: September 18, 2014, 03:32:29 PM »
I added some extra checks to the repository to get around this. Best you can do is what I already mentioned -- don't move the UI camera, or make sure that the panel you're moving is a sibling of the camera, not its child and not its parent.