Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: roder on October 13, 2013, 08:26:47 PM

Title: Load level
Post by: roder on October 13, 2013, 08:26:47 PM
I have a scene with a 3d object is spinning, the 3D object you've added your respective boxcolider and tried to add the following script, so that when you touch this open aprecer a scene but does not work and is ignoring me
as you can see I have tried to do modifying a  ngui script to achieve it

Also try using in a button but got no result

  1. /// <summary>
  2. /// Plays the specified sound.
  3. /// </summary>
  4.  
  5. [AddComponentMenu("NGUI/Examples/Load Level On Click")]
  6. public class LoadLevelOnTap : MonoBehaviour
  7. {
  8.         public string levelName;
  9.         public enum Trigger
  10.         {
  11.                 OnClick,
  12.                 OnMouseOver,
  13.                 OnMouseOut,
  14.                 OnPress,
  15.                 OnRelease,
  16.         }
  17.  
  18.         public Trigger trigger = Trigger.OnClick;
  19.        
  20.         void OnHover (bool isOver)
  21.         {
  22.                 if (enabled && ((isOver && trigger == Trigger.OnMouseOver) || (!isOver && trigger == Trigger.OnMouseOut)))
  23.                 {
  24.                 Application.LoadLevel(levelName);
  25.                 }
  26.         }
  27.  
  28.         void OnPress (bool isPressed)
  29.         {
  30.                 if (enabled && ((isPressed && trigger == Trigger.OnPress) || (!isPressed && trigger == Trigger.OnRelease)))
  31.                 {
  32.                 Application.LoadLevel(levelName);
  33.                 }
  34.         }
  35.  
  36.         void OnClick ()
  37.         {
  38.                 if (enabled && trigger == Trigger.OnClick)
  39.                 {
  40.                 Application.LoadLevel(levelName);
  41.                 }
  42.         }
  43. }
Title: Re: Load level
Post by: ArenMook on October 13, 2013, 09:11:15 PM
You need a UICamera script on your main camera, or no events will be sent.
Title: Re: Load level
Post by: roder on October 13, 2013, 09:23:13 PM
Ive already have a uiroot3d with a camera and uicamera script
Title: Re: Load level
Post by: ArenMook on October 13, 2013, 09:25:22 PM
What for? You don't need a 3D UI to get events on an in-game object. You need a UICamera script on your Main Camera.

Bottom line is -- the camera that sees the object is the one that needs a UICamera on it. And it must have the Event Mask set up where the object you're interacting with is not masked out.