Unity Community |

Hello,
I'm working on a mobile game that uses the accelerometer and gyroscope. When deployed to an android device, the game works well in the beginning. However, if the device sleeps, when I wake it up and try to continue playing the gyroscope, and accelerometer both stop working. Is there a way to hook into the android life cycle functions without writing a custom activity? The script that I'm using to update the gravity direction is below. It's very simple and does the job, until the phone sleeps. Also, can I provide a custom manifest without overriding the default unity activity (for using-permissions)?
Code:
using UnityEngine; using System.Collections; { public float m_gravity = -29.8f; // Use this for initialization { //Doesn't always work unless I put this here. //TODO: reorient camera in scene to avoid transforming frame in scripts } // Update is called once per frame { //I always see this, even after waking up //This makes no difference here } }
Have you tried turning off sleep?
Code:
May not suit your exact app but...
Hi John,
Thanks for the suggestion. It does prevent the problem and the annoyance of the screen dimming during play. The only thing I did different is that I used the unity constant.
Code:
Cheers