Disabling UI while audio is playing
Hello!
I am very new to coding, I have used the native UI controls in Unity along with a simple script that changes scenes to create a simple quiz app.
Now I want to add a feature to improve the UX, which I have not been able to find specific enough examples for that I am able to adapt it to my project. I want to disable UI input (pushing buttons) whenever audio is playing. I would prefer to do it using a universal script, which I can run on the splash screen, so it remains active throughout the app but I fear that might be a bridge too far at this stage and should be reserved for later when I have become a better programmer (baby steps and all that). My grasp of syntax is still very poor, so I am having trouble adapting the examples that I find to my situation.
I don't mind manually adding the script to each button in each scene. Clumsy but simple is very much fine for me. That way I understand what is going on.
if audio.isPlaying == true
then allButtons.interactable = false
//if audio is playing, the user can't press any buttons
else allButtons.interactable = true
//if audio is not playing, the user is allowed to press any of the buttons!
The above is pretty much the gist of what the script looks like in my head. I am aware that the syntax is horrible and it will never work in that state but hopefully it conveys what I want it to do.
I hope that preventing the user from pushing new buttons while audio is playing is a relevant enough UX-feature that I am not wasting everybody's time and I hope that the solution is simple enough that the answer is easy enough for me to understand. Thank you for reading! =)
Your answer
Follow this Question
Related Questions
sound on button hold only/pause other sounds 0 Answers
How do i make Unity seamlessly loop my background music? 5 Answers
iOS Audio Skipping Tracks 0 Answers
Audio wont Play when in an if statement 0 Answers
Cannot Figure out How to use panStereo 0 Answers