Author Topic: Anchors change on their own with 2 UI Roots  (Read 1709 times)

JumpDog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Anchors change on their own with 2 UI Roots
« on: August 12, 2014, 07:45:41 PM »
Hello, I have a potentially very specific issue I'm facing. Maybe not, but feels like it.

Today I was reworking the UI in my game and splitting it into two parts, including one that is persistent and is not destroyed on loading other scenes - to carry all the panels and windows that are present in all scenes, rather than having to reload them in each one. So right now, I have a persistent UI Root, as well as one other UI Root in each scene with scene-specific windows.

Unfortunately... any anchored content in the scene-specific UIs will now, at scene load, move and anchor themselves to the persistent UI's root. Considering they are at different positions in space, this is not desired and I have yet to be able to find a workaround for it, sitting here tinkering with it for a while now.

Not sure why this is happening. To be clear, the anchor values are NOT changing. It still SAYS that it's anchored to the appropriate UI root, with the same values... but it's local position snaps to the persistent root. Thanks for any help.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Anchors change on their own with 2 UI Roots
« Reply #1 on: August 13, 2014, 07:45:34 AM »
Different UIRoots implies different cameras as well. If they happen to be on the same layer, then UICamera.FindCameraForLayer likely returns the wrong one for you. You need to use different layers if you have different roots.

JumpDog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Anchors change on their own with 2 UI Roots
« Reply #2 on: August 13, 2014, 07:21:40 PM »
Thanks a bunch, that did the trick. Was unaware it was set up to auto-find that.