Accessing the Android sensors and features within Unity 5
Let's discover a little bit more about some Android sensors and features that are shown in the simple code examples later in text.
Acceleration
You can also access the Android acceleration inside Unity. Let's upgrade our previous example, so we can see one more aspect of our Android device. The new piece of code is shown here:
GUILayout.Label("\n\n A C C E L E R A T I O N"); GUILayout.Label("Input.acceleration = (" + Input.acceleration.x + ", " + Input.acceleration.y + ", " + Input.acceleration.z + ")");
After running this test on your Android device, you will see how acceleration values change very quickly in real time.
Gyroscope
Unity provides gyroscope access on Android devices as shown in the new piece of code. Before using gyroscope, you just need to enable it as shown here:
Input.gyro.enabled = true; GUILayout.Label("\n\n G Y R O S C O P E"); GUILayout...