Author Topic: Problem with 3-D UI and Prefabs  (Read 3313 times)

ironwill96

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
Problem with 3-D UI and Prefabs
« on: July 27, 2014, 01:24:05 PM »
Hi - long-time user and lurker here (bought NGUI originally in the very first week you released it and asked you questions about it on the Unity launch thread and then bought the version 3.x a few weeks ago when I got back into Unity again).

I created a 2-D UI and then later converted it to 3-D UI because I wanted to rotate elements to look a bit nicer in my main menu scene.  The problem I am having is that I wanted to use the checkbox prefabs but as soon as I start dragging them into the scene, NGUI spawns dozens of UIRoots into the scene and then the UI stops working entirely.  I tried with a fresh scene and was able to duplicate this behavior by creating a 2-D UI, prefabs work fine.  Create a 3-D UIRoot and prefabs will spawn tons of extra UIRoots.  Are prefabs intended to only work with 2-D UIs?

I am probably doing something really silly but would appreciate anyone's advice/help with this!

Thanks,
Nathan

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problem with 3-D UI and Prefabs
« Reply #1 on: July 27, 2014, 11:09:58 PM »
Control Prefabs that come with NGUI's examples are on the 2D UI layer, so they always try to parent themselves underneath the appropriate game object when you drag them into the scene. They shouldn't be creating any other extra UI roots however. I just did a quick test on my end -- created a 2D UI, then a 3D UI, and dragging in prefabs from the Prefab Toolbar automatically adds them to the 2D UI's hierarchy, as expected.

ironwill96

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Problem with 3-D UI and Prefabs
« Reply #2 on: July 28, 2014, 08:07:49 AM »
OK i'll give that a shot.  What I had done was create a 3-D UIRoot (don't create a 2-D one), then try to drag a prefab onto the scene view and it creates at least 6 (sometimes a lot more) 2D UIRoots.  It seems to create them as long as you are hovering over the scene view or moving around.

Once I have it on the 2-D uiroot, can I just move it over to the 3-D one and delete the 2-D?  I tried doing that and then my UI disappears completely (the 3-D and the 2-D elements).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problem with 3-D UI and Prefabs
« Reply #3 on: July 29, 2014, 03:11:10 AM »
NGUI's panels force everything underneath them to assume the same layer, so moving something from A to B isn't enough -- you also need to change the layer. The best way to facilitate this is to disable the object you want to move, change its layer while it's disabled, and only then move it over.