Author Topic: making a 3D game object as a button  (Read 4119 times)

patrick_activate

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
making a 3D game object as a button
« on: February 17, 2014, 10:52:43 PM »
hello, i have a game object which includes a model and animation. i wish to make it works like button in NGUI UI, is it possible?

Tom1989

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: making a 3D game object as a button
« Reply #1 on: February 18, 2014, 08:29:00 AM »
Put a collider on it and raycast. Check the GameObject name or tag to see if it is your "Button" or not. If it is then fire your functionality from there

patrick_activate

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: making a 3D game object as a button
« Reply #2 on: February 18, 2014, 08:42:54 PM »
thanks for replying, that works, but now i faces another problem, i am using NGUI, and the 3D game object button being blocked by the background UI, i want the 3D object button to be appear at the front of background UI, how could i achieve that? which NGUI script should i attach to the 3D object button so that i can change its depth value?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: making a 3D game object as a button
« Reply #3 on: February 19, 2014, 12:31:23 PM »
UICamera set to "UI" event mode will always sort by widget depth. In your case you are trying to use a non-widget, so it has no depth. UICamera set to "World" mode will sort by distance to the collider hit, which won't work properly with UI but will work correctly with 3D objects.

Bottom line is... to do what you're trying to do properly, you need to draw your object into a render texture, then use UITexture to draw this render texture. This is the only way it will all work correctly as UITexture is a widget.