- Home /
Add sound effect when phone device is on low battery
I'm working on a game where I want the game to play a sound effect when a device reaches low battery condition. like this Bop It does: https://www.youtube.com/watch?v=UzgBUPCYmeY
I want a sound/notifcation to pop up and say: Your phone battery is running low
and play a sound effect. Is this possible?
Answer by DenisIsDenis · Jun 07, 2021 at 11:58 AM
You can use SystemInfo.batteryLevel
to check the battery level:
if (0 /* 0% */ <= SystemInfo.batteryLevel && SystemInfo.batteryLevel <= 0.1f /* 10% */)
{
/*SHOW MESSAGE & PLAY SOUND*/
}
More about SystemInfo.batteryLevel:
https://docs.unity3d.com/ScriptReference/SystemInfo-batteryLevel.html
Your answer
Follow this Question
Related Questions
Audio source playing different soundfiles 0 Answers
Increase the volume of sound source past limit? 1 Answer
GetSpectrumData works only for 3 sec of microphone input 0 Answers
mute/un-mute 1 Answer
simulate DJ scratching 0 Answers