I have tryed to do that "If you want to do more advanced GDK methods you will need to register an AndroidJavaClass and extend UnityPlayerNativeActivity. Once you do that you can register a GestureDetector in Android and pass the results back to Unity using UnityPlayer.UnitySendMessage(); This also works with Voice Transcriptions and other GDK results.", using the code proposed by jainam here
But My UnityPlayerNativeActivity can't send the message to Unity, I don't Know why.
My quick solution has been the next (pending of optimize):
touches = int.Parse(AndroidInput.touchCountSecondary.ToString());
if (touches > 0) {
Debug.Log("TOUCHE");
xCurrent = AndroidInput.GetSecondaryTouch(0).position.x;
yCurrent = AndroidInput.GetSecondaryTouch(0).position.y;
if(xInitial == -1 && yInitial == -1){
xInitial = xCurrent;
yInitial = yCurrent;
}
}else if(xInitial > -1 && yInitial > -1){
if(yCurrent < yInitial && yCurrent == 0){
Debug.Log("Swap down");
Application.Quit();
}else if(xCurrent - xInitial < -100){
Debug.Log("Swap Right");
}else if(xCurrent - xInitial > 100){
Debug.Log("Swap Left");
}else{
Debug.Log("Tap");
}
xInitial = yInitial = xCurrent = yCurrent = -1;
}
What do you think about this solution?
does exist any solution to the UnityPlayerNativeActivity?