Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: patrick_activate on February 17, 2014, 10:52:43 PM

Title: making a 3D game object as a button
Post by: patrick_activate 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?
Title: Re: making a 3D game object as a button
Post by: Tom1989 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
Title: Re: making a 3D game object as a button
Post by: patrick_activate 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?
Title: Re: making a 3D game object as a button
Post by: ArenMook 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.