Author Topic: Trying to combine NGUI with FingerGestures.  (Read 3907 times)

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Trying to combine NGUI with FingerGestures.
« on: May 17, 2013, 07:30:41 PM »
Hey Guys,

I am not sure if I should post this here at the NGUI forum or that I should post it at FingerGestures. What I am doing is that I have a UIDragablePanel with a grid and in that grid there are 3 screens. I want it to act like the home screen of the iPhone. This I can not accomplish with the normal functionality of the UIDragablePanel. So I am trying to combine NGUI with the FingerGestures plugin. I am able to detect swipes and everything and my panel works fine but when I combine them I get all this strange behaviour. What happens is that it either jumps too far or not far enough. And then when it turns the center on child back on (as you can see in the code I turn it off for a short amount of time) it doesn't center on the middle of either objects but somewhere else I will also include a screenprint of this.

following is a code snippet of what I have right now.
  1. function OnSwipe (gesture : SwipeGesture){
  2.         var panelPosition : float;
  3.         panelPosition = panel.transform.localPosition.x;
  4.         grid.GetComponent(UICenterOnChild).enabled = false;
  5.                 if(gesture.Direction == FingerGestures.SwipeDirection.Left){
  6.                
  7.                         switch(true){
  8.                                 case ((panelPosition > -1150) && (panelPosition < 0) || panelPosition == 0) :
  9.                                 panel.transform.localPosition.x = -1150;
  10.                                 //panel.animation.Play("MovePanelAnim1");
  11.                                 yield;
  12.                                 grid.GetComponent(UICenterOnChild).enabled = true;
  13.        
  14.                                 break;
  15.                                 case((panelPosition > -2300) && (panelPosition < -1150) || panelPosition == -1150) :
  16.                                 //panel.animation.Play("MovePanelAnim2");
  17.                                 panel.transform.localPosition.x = -2300;
  18.        
  19.                                 yield ;
  20.        
  21.                                         grid.GetComponent(UICenterOnChild).enabled = true;
  22.        
  23.                                
  24.                                 break;
  25.                                
  26.                                 case (panelPosition < -2300):
  27.                                        
  28.                                         grid.GetComponent(UICenterOnChild).enabled = true;
  29.                                 break;
  30.                                
  31.                                
  32.                         }
  33.                
  34.                 }
  35.                
  36.                 if(gesture.Direction == FingerGestures.SwipeDirection.Right){
  37.                         switch(true){
  38.                                 case ((panelPosition > -2300) && (panelPosition < -1150) || panelPosition == -2300):
  39.                                         //panel.animation.Play("MovePanelAnim3");
  40.                                         panel.transform.localPosition.x = -1150;
  41.        
  42.                                 yield;
  43.                                         grid.GetComponent(UICenterOnChild).enabled = true;
  44.                                 break;
  45.                                 case ((panelPosition > -1150) && (panelPosition < 0) || panelPosition == -1150):
  46.                                         //panel.animation.Play("MovePanelAnim4");
  47.                                         panel.transform.localPosition.x = 0;
  48.        
  49.                                 yield ;
  50.                                         grid.GetComponent(UICenterOnChild).enabled = true;
  51.                                 break;
  52.                                
  53.                                 case (panelPosition == 0 || panelPosition > 0):
  54.                                         grid.GetComponent(UICenterOnChild).enabled = true;
  55.        
  56.                                 break;
  57.                         }
  58.                 }
  59.                
  60. }

As you can see in the code that is commented out I also tried using animations but without any succes. I also tried using while loops but this gave me the same behaviour.

I hope someone has a suggestion for me.

Kind Regards,
Max Uijlings