How to make volume continually go down in C#Script ?

Hello everyone !

I’ve been searching on this website for a few days now and haven’t quite found what I was looking for, so I hope one of you will be able to save me !

Here’s what I’m looking for, I have an audioclip inside a script, playing music for my main scene. What I want to do is to make the music fade out all the time because in my game, when the volume of the music gets to zero, it’s Game Over. But the player can raise the volume up by collecting some sort of “power-up” objects, and the music fades out again until he finds another object, and so on until the player finishes the level.

I hope I’ve been clear enough, here’s what my code looks like for now, it’s attached to my player, thank you !

using UnityEngine;
using UnityEngine.Audio;
using System.Collections;

public class Audio : MonoBehaviour {


	public AudioSource Mainaudio;
	public float volume = 0f;

	// Use this for initialization
	void Start () {

		Mainaudio.Play ();

	}


	void OnTriggerEnter2D(Collider2D other){

		if (other.gameObject.tag == "Power Up") {


		}

	}

	void Update () {
	

		Mainaudio.volume = 0.5f;
		

	}
}

IEnumerator goDownforWhat ()
{

          yield return new WaitForSeconds (0.3f);
          mainaudio.volume -= 0.5f;
       
      }

Just for anyone else coming across this later, another solution would be as follows:

void Update(){
    Mainaudio.Volume -= Time.deltaTime * speedMultiplier;
}

This would make the volume decrease by 1 for each second that passes, if speedMultiplier == 1.
If speedMultiplier == 2, then for each second that went past it would reduce by 2 volume points, etc.