@@ -64,15 +64,9 @@ public class JCS_2DSlideScreenCamera
6464
6565 [ Header ( "## Mobile" ) ]
6666
67- [ Tooltip ( "Distance to slide over next scene on x axis." ) ]
68- [ Range ( 0.0f , 5000.0f ) ]
67+ [ Tooltip ( "Area space to swipe for previous/next page." ) ]
6968 [ SerializeField ]
70- private float mSwipeDistanceX = 5.0f ;
71-
72- [ Tooltip ( "Distance to slide over next scene on y axis." ) ]
73- [ Range ( 0.0f , 5000 ) ]
74- [ SerializeField ]
75- private float mSwipeDistanceY = 5.0f ;
69+ private Vector2 mSwipeArea = new Vector2 ( 0.5f , 0.5f ) ;
7670
7771 [ Tooltip ( "Freeze the x axis sliding action." ) ]
7872 [ SerializeField ]
@@ -115,6 +109,7 @@ public class JCS_2DSlideScreenCamera
115109 public JCS_SlideScreenPanelHolder PanelHolder { get { return this . mPanelHolder ; } set { this . mPanelHolder = value ; } }
116110 public void SetJCS2DCamera ( JCS_2DCamera cam ) { this . mJCS_2DCamera = cam ; }
117111 public JCS_UnityGUIType UnityGUIType { get { return this . mUnityGUIType ; } set { this . mUnityGUIType = value ; } }
112+ public Vector2 SwipeArea { get { return this . mSwipeArea ; } set { this . mSwipeArea = value ; } }
118113 public bool FreezeX { get { return this . mFreezeX ; } set { this . mFreezeX = value ; } }
119114 public bool FreezeY { get { return this . mFreezeY ; } set { this . mFreezeY = value ; } }
120115 public AudioClip SwitchSceneSound { get { return this . mSwitchSceneSound ; } set { this . mSwitchSceneSound = value ; } }
@@ -351,17 +346,21 @@ private void DoMobileSwipe()
351346
352347 if ( JCS_Input . GetMouseButtonUp ( JCS_MouseButton . LEFT ) )
353348 {
354- Vector3 posDiff = mPanelHolder . PositionDiff ( ) ;
349+ Vector3 posDiff = si . DragDistance ;
350+ JCS_ScreenSizef vs = JCS_ScreenSettings . instance . VisibleScreenSize ( ) ;
351+ JCS_ScreenSizef target_vs = new JCS_ScreenSizef ( vs . width * mSwipeArea . x , vs . height * mSwipeArea . y ) ;
355352
356- if ( ! mFreezeX && posDiff . x > this . mSwipeDistanceX )
353+ if ( ! mFreezeX && posDiff . x > target_vs . width )
357354 {
355+ print ( posDiff ) ;
356+
358357 if ( JCS_Mathf . IsPositive ( si . DragDisplacement . x ) )
359358 SwitchScene ( JCS_2D4Direction . LEFT ) ;
360359 else
361360 SwitchScene ( JCS_2D4Direction . RIGHT ) ;
362361 }
363362
364- if ( ! mFreezeY && posDiff . y > this . mSwipeDistanceY )
363+ if ( ! mFreezeY && posDiff . y > target_vs . height )
365364 {
366365 if ( JCS_Mathf . IsPositive ( si . DragDisplacement . y ) )
367366 SwitchScene ( JCS_2D4Direction . BOTTOM ) ;
0 commit comments