Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: MaxUylings on September 25, 2012, 05:54:54 AM

Title: Scrollable menu
Post by: MaxUylings on September 25, 2012, 05:54:54 AM
Hey,

I want to create a menu for iOS to select different worlds. What I did was I took the example nr7 from the documentation to create a scrollable list of buttons. Then I created the following script to make sure that when you swipe the buttons do not get clicked. I was wondering what you guys think about the way I did this.

  1. #pragma strict
  2.  
  3. enum WereldTrigger{
  4. OnPress,
  5. OnRelease,
  6. }
  7.  
  8. var trigger : WereldTrigger = WereldTrigger.OnPress;
  9. var scene : String;
  10.  
  11.  
  12. function OnPress (isPressed : boolean){
  13.        
  14.         if(this.transform.position.x < 0.001f && this.transform.position.x > -0.001f){
  15.                 Debug.Log("Position is correct");
  16.                 if (!isPressed && trigger == WereldTrigger.OnRelease){
  17.                                 Application.LoadLevel(scene);
  18.                         Debug.Log("Button clicked");
  19.                 }
  20.         }
  21.         else{
  22.         Debug.Log("Button Swiped");
  23.        
  24.         }
  25.  
  26. }
  27.  
  28.  

Kind Regards,
Max Uijlings
Title: Re: Scrollable menu
Post by: ArenMook on September 25, 2012, 08:33:37 AM
There is a similar threshold setting already present on the UICamera.
Title: Re: Scrollable menu
Post by: MaxUylings on September 26, 2012, 04:35:57 AM
Thank you that works better then my solution. I just had one question the numbers that you specify "mouse drag threshold 4" is that in pixels?

Kind Regards,
Max Uijlings
Title: Re: Scrollable menu
Post by: PhilipC on September 26, 2012, 08:23:52 AM
Yes that should be in pixels.
Title: Re: Scrollable menu
Post by: MaxUylings on September 26, 2012, 09:07:34 AM
Great thanks! :)