question

jhample avatar image
jhample asked

Unity OnApplicationFocus Issues

I am having problems with controller and remote input not resetting after my app loses/gains focus. When I have a popup overlay such as for IAP or GameCircle I am having issues where upon return from the overlay, the controller still thinks that some buttons pressed before or while the overlay was shown are still being pressed. These issues do not occur 100% of the time. Maybe 60-70%. I have attempted to fix this by adding Input.ResetInputAxes() just about everywhere I can related to IAP and GameCircle and in OnApplicationFocus. I even have it set to loop Input.ResetInputAxes() for a half of a second before allowing any more input after returning. But still the buttons do not always reset. It is possible that I may have made some mistakes while coding my menu controls, but I feel like there may be some larger issue here either with Unity? If anyone else could test this and verify that it works/doesn't work it would be greatly appreciated. My current test has text mesh on screen with the following code: string text = "joy0: " + Input.GetKey(KeyCode.JoystickButton0) + "\n" + "joy1: " + Input.GetKey(KeyCode.JoystickButton1) + "\n" + "joy2: " + Input.GetKey(KeyCode.JoystickButton2) + "\n" + "joy3: " + Input.GetKey(KeyCode.JoystickButton3) + "\n" + "x: " + Input.GetAxis("Horizontal") + "\n" + "y: " + Input.GetAxis("Vertical"); To test hold a button (sometimes you don't even have to hold even taps will stick sometimes) while either launching the GameCircle overlay or while initiating an IAP. Exit the overlay or complete the purchase and you may notice that the button you were pressing before the overlay came up is still set to 1. It will stay true until you press that button again. If anyone has seen this issue and knows what to do to fix it please let me know. I have been stumped on it for a couple days and it is the last thing I need to fix before submitting my game.
fire tv
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DougM@Amazon avatar image
DougM@Amazon answered
Hello jhample , Sorry for the delayed response. For issues such as input sticking on the OnApplicationFocus() callback, we generally have seen developers successfully get around it by ignoring input events for a number of frames until the input events reset to a known state. However, if you are still experiencing issues with input on FireTV in Unity, we would need to know what version of the Engine you are implementing your games in so that way we can take a closer look into what would be a good resolution for your particular question.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dylan Wolf avatar image
Dylan Wolf answered
I'm running into the same problem using Unity 4.6.1f1 and GameCircle plugin 2.5.2. In my case, I'm triggering the overlays off the D-pad on the FireTV remote. I've written code that prevents further actions until the axis re-centers to 0, but it sometimes takes a few seconds to do this.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dylan Wolf avatar image
Dylan Wolf answered
I'm also seeing this with UI overlays on Nexus Player with Google Play game services, so this appears to be a Unity issue rather than Amazon specific issue.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.