Toggle Sound and Prefab Activation on Button Click in Unity
Toggle Sound and Prefab Activation on Button Click in Unity
This Unity script plays a sound and activates a prefab when a button is clicked. If the button is clicked again while the sound is playing, it stops the sound and deactivates the prefab. The script ensures that the prefab is only active while the sound is playing, providing a simple yet effective way to manage audio and visual feedback in your Unity project.