Hi,
On my game, whenever I call LoadLevel("mylevel") from a swipe event it crashes, the same LoadLevel("mylevel") works fine if I call it from a button click event.
I tested swipe with other calls (I show a dialog box when a swipe event is triggered) and it works fine.
Here is my swipe code:
void Update () {
if (Input.touchCount > 0){
for(int i = 0; i minSwipeDist){
Vector2 direction = touch.position - fingerStartPos;
Vector2 swipeType = Vector2.zero;
if (Mathf.Abs(direction.x) > Mathf.Abs(direction.y)){
// the swipe is horizontal:
swipeType = Vector2.right * Mathf.Sign(direction.x);
}else{
// the swipe is vertical:
swipeType = Vector2.up * Mathf.Sign(direction.y);
}
if(swipeType.x != 0.0f){
if(swipeType.x > 0.0f){
// MOVE RIGHT
//SwipeH();
MobileNativePopups.OpenAlertDialog(
"Swipe", "MOVE RIGHT",
"Cancel", () => { Debug.Log("Cancel was pressed"); });
}else{
// MOVE LEFT
MobileNativePopups.OpenAlertDialog(
"Swipe", "MOVE LEFT",
"Cancel", () => { Debug.Log("Cancel was pressed"); });
}
}
if(swipeType.y != 0.0f ){
if(swipeType.y > 0.0f){
// MOVE UP
MobileNativePopups.OpenAlertDialog(
"Swipe", "MOVE UP",
"Cancel", () => { Debug.Log("Cancel was pressed"); });
}else{
// MOVE DOWN
MobileNativePopups.OpenAlertDialog(
"Swipe", "MOVE DOWN",
"Cancel", () => { Debug.Log("Cancel was pressed"); });
}
}
}
break;
}
}
}
}
public void SwipeHandler(){
GameTimer.ResetGamePlay();
Application.Quit();
Application.LoadLevel ("startscreen");
}
public void SwipeHandler2(){
GameTimer.ResetGamePlay();
Application.Quit();
Application.LoadLevel ("Level_ag-01");
}
public void SwipeHandler3(){
GameTimer.ResetGamePlay();
Application.Quit();
Application.LoadLevel (Application.loadedLevel + 1);
}
void SwipeH(){
if (type == 0)
SwipeHandler ();
else if (type == 1) {
SwipeHandler2 ();
} else if (type == 2) {
SwipeHandler3();
}
}
Thank you for your help
↧