MIF_E31222398/Assets/MuteSoundtrack.cs

40 lines
812 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MuteSoundtrack : MonoBehaviour
{
public AudioSource soundtrackMateri;
public Image muteButton;
public Sprite MuteButton;
public Sprite UnmuteButton;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void MuteSountrack()
{
if (soundtrackMateri.volume == 0.0f)
{
muteButton.sprite = UnmuteButton;
soundtrackMateri.volume = 0.7f;
}
else if (soundtrackMateri.volume == 0.7f)
{
muteButton.sprite = MuteButton;
soundtrackMateri.volume = 0.0f;
}
}
}