-
Notifications
You must be signed in to change notification settings - Fork 0
/
setvol.cs
42 lines (37 loc) · 1.03 KB
/
setvol.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Audio;
//This class contain the script for the global variables.
public class setvol : MonoBehaviour
{
public AudioMixer mixer;
public static bool isHard = false;
public static bool paused = false;
private setvol instance;
//This function set all instance of this object to the first instance.
void Start()
{
if (instance == null)
{
instance = this;
}
else
{
Destroy(gameObject);
return;
}
DontDestroyOnLoad(gameObject);
}
//This function set the volume of the music and sound effects.
public void SetLevel(float slidervalue)
{
mixer.SetFloat("MusicVol", Mathf.Log10(slidervalue) * 20);
}
//This function set the game difficulty.
public void changedifficulty()
{
isHard = !isHard;//changes difficulty
}
}