Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: pushxtonotdie on May 25, 2012, 02:39:08 PM

Title: Using UI without camera
Post by: pushxtonotdie on May 25, 2012, 02:39:08 PM
I'd like to use the NGUI framework as items within the scene. In my case there is a tooltip in 3d space that would be clickable. I have created a new UI without a camera by selecting 'none' in the UI panel. I can create and display my UI without issue, but items are not clickable. Is it possible to use NGUI without requiring a camera object at the top of the hierarchy?
Title: Re: Using UI without camera
Post by: pushxtonotdie on May 25, 2012, 04:13:57 PM
After looking around it seems that the interaction of the basic UIButton* scripts all require a UICamera. I have made a quick adapter to more easily use these components without a UI Component:

  1.         public void OnMouseEnter(){
  2.                 SendMessage("OnHover", true, SendMessageOptions.DontRequireReceiver);
  3.         }
  4.  
  5.         public void OnMouseExit(){
  6.                 SendMessage("OnHover", false, SendMessageOptions.DontRequireReceiver);
  7.         }
  8.  
  9.         public void OnMouseDown()
  10.         {
  11.                 SendMessage("OnPress", true, SendMessageOptions.DontRequireReceiver);
  12.         }
  13.  
  14.         public void OnMouseUp()
  15.         {
  16.                 SendMessage("OnPress", false, SendMessageOptions.DontRequireReceiver);
  17.         }
  18.  

This seems to work if I put it on a button (or I guess similar control).
Title: Re: Using UI without camera
Post by: ArenMook on May 25, 2012, 05:01:09 PM
You need the UICamera component on your game camera, or nothing seen by the game camera will be capable of receiving events.

Just attach a UICamera to your game camera.