Author Topic: Scrollable menu  (Read 4012 times)

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Scrollable menu
« 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollable menu
« Reply #1 on: September 25, 2012, 08:33:37 AM »
There is a similar threshold setting already present on the UICamera.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Scrollable menu
« Reply #2 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

PhilipC

  • Guest
Re: Scrollable menu
« Reply #3 on: September 26, 2012, 08:23:52 AM »
Yes that should be in pixels.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Scrollable menu
« Reply #4 on: September 26, 2012, 09:07:34 AM »
Great thanks! :)