Author Topic: Issue with Prefab'ing a 2D UI  (Read 1827 times)

omskillet

  • Guest
Issue with Prefab'ing a 2D UI
« on: November 27, 2013, 11:43:42 PM »
Whenever I create a prefab of a 2D UI setup and then add it back to a new scene with a player in it ( a la a pause menu ) the UI is no longer rendered in screen space. I can see it being rendered out in the world but it doesn't follow the player. If I create one from the NGUI menu with the same scene everything works fine. Any ideas?

Also whenever I create a new 2D UI the layers always default to whatever is in layer 8. Is that the desired behavior?

Quarkism

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: Issue with Prefab'ing a 2D UI
« Reply #1 on: November 28, 2013, 12:02:22 AM »
Try checking the layers. Including parents. I noticed this happens when I have a container object in the default layer.

omskillet

  • Guest
Re: Issue with Prefab'ing a 2D UI
« Reply #2 on: November 28, 2013, 02:55:00 PM »
I have the UI Root and all its children in a layer called GUI. The player camera is in a mixed layer. Not sure what I'm doing wrong here.

Test case for me:

1. In an empty scene create a simple 2D UI.
2. Add a basic sprite.
3. Rename the UI root to "TestPrefab"
4. Drag to Prefab folder.
5. Close the scene.
6. Open scene with my custom player controller.
7. Drag in the TestPrefab

Notice the GUI sits in the world and not on the player screen

If I repeat steps 1 and 2 in the scene with the player controller everything works as I expect.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Issue with Prefab'ing a 2D UI
« Reply #3 on: November 28, 2013, 03:38:12 PM »
Select your Main Camera and modify its Culling Mask so that it's not drawing your UI layer anymore.