Author Topic: How to make 3D widgets?  (Read 6602 times)

bkinsey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 30
    • View Profile
How to make 3D widgets?
« on: September 16, 2014, 03:02:49 PM »
Is there a tutorial on creating 3d UI widgets?  What I would like to do is have images and text that are displayed in 3d space, in difference parts of the world. For example, imagine a 3d Mario hitting a block and having a coin image float up into the sky. I want to have similar kinds of notifications floating up, in the world.  Is this possible?

(From the NGUI menu option I created a "3D UI" object, which gives me two UI Root objects in my Hierarchy. I copied a Container, Label, and Sprite from my "UI Root" object to the "UI Root (3D)" object, but not seeing it.. I only see my 2D widget.)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make 3D widgets?
« Reply #1 on: September 17, 2014, 11:58:28 AM »
1. New game object on a layer that's visible by your main camera, such as Default.

2. Attach UIPanel to it. Scale it down to something small, such as (0.01, 0.01, 0.01)

3. You can now add widgets to it as usual. ALT+SHIFT+S with it selected, for example.

No need for UI Root at all.

bkinsey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: How to make 3D widgets?
« Reply #2 on: September 17, 2014, 11:08:26 PM »
Awesome!!!!  So excited that its that easy.

Does each Panel result in an added draw call?  Also, is there a significant perf hit for leaving the scale alone for the panel?  If I change the scaling, then I have to change all my x/y/z values.. its more convenient to work with the same values across panels.

I might have up to 5 of these floating notifications on the screen at once, in addition to my normal UI, however they will delete themselves after the notification times out in 3 seconds.

bkinsey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: How to make 3D widgets?
« Reply #3 on: September 18, 2014, 02:14:19 AM »
Ok next issue. Do we support 3D buttons?

1. Created GameObject
2. Added Panel as a child
3. Added Sprite as a child of Panel
4. Added UIButton component to Sprite. Set Normal and Pressed Sprites in Inspector.
5. Attached Box Collider.

All of the above are in the Default layer. (Which per my understanding is how 3d UI is supposed to be configured)

I see the sprite in my Game tab. When I press play, the sprite does not change when I hover over it, or press down on it with my mouse.  However, if I move this sprite to be a child of UI Root, it responds to mouse over, and pressing on the button results in a changed image.

bkinsey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: How to make 3D widgets?
« Reply #4 on: September 18, 2014, 11:18:50 AM »
Answering my own question: Attach a "UI Camera" aka ngui event system component to my main camera. :D