Author Topic: Difficulty converting 2D UI to 3D  (Read 2274 times)

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Difficulty converting 2D UI to 3D
« on: July 01, 2017, 11:23:49 AM »
Heya! I'm returning to work on a game I hadn't touched in years (I think it was ngui 3.3.x or such?), and after updating Unity and my Libraries and getting everything sorted, I'm trying to convert my ui to 3D. It mostly seems in place except for a strange behaviour where when I start my game, it generates a TON of additional UIRoots with Cameras, and renders the scene in Ortho again.
The main camera that existed before running has it's culling changed from Everything to mixed (all but UI) so it doesnt render the 3D ui, and if I delete all the new UIRoots the ortho gui disappears, and resetting the main camera's culling back to everything renders it correctly in 3d.
I can interact with basic elements (scrolling, hovering, clicking things that just play tweens), but when I try to open a new menu it spawns a whole new batch of UIRoots and does the same culling change, ortho view, etc.
The code that seems to trigger it is NGUITools.AddChild:
  1. CorporationMenu menu = NGUITools.AddChild(this.CenterView, this.CorporationMenu.gameObject).GetComponent<CorporationMenu>();

Does this sound like something you recognize? Let me know if you need additional information.


sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Re: Difficulty converting 2D UI to 3D
« Reply #1 on: July 01, 2017, 11:31:47 AM »
showing the main UIRoot and Camera, and the ton of UI Roots that are added when it starts or when I try to addChild.

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Re: Difficulty converting 2D UI to 3D
« Reply #2 on: July 04, 2017, 11:06:06 AM »
Did some experimenting and this seems directly related to switchign my camera to "perspective". If I leave it as Ortho, it runs like normal, no new UIRoots are generated, but if I switch it to perspective it breaks the cam and spams new UIRoots as mentioned above.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Difficulty converting 2D UI to 3D
« Reply #3 on: July 06, 2017, 05:54:00 AM »
Make sure your UI is on the layer you expect it to be... that's about all I can think of. You can also add a Debug.Log to the NGUITools.CreateUI function to see where it's called from and why. The UIRoot is only added there (line 897).