-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToggleAudio.cs
More file actions
48 lines (42 loc) · 1.16 KB
/
Copy pathToggleAudio.cs
File metadata and controls
48 lines (42 loc) · 1.16 KB
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
43
44
45
46
47
48
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ToggleAudio : MonoBehaviour
{
//[SerializeField] RectTransform uiHandleRectTransform;
[SerializeField] private Toggle toggleMusic, toggleEffects;
//Vector2 handlePostion;
bool muteMusic;
void Start()
{
if (!PlayerPrefs.HasKey("muteMusic"))
{
PlayerPrefs.SetInt("muteMusic", 0);
LoadMusicPref();
}
else
{
LoadMusicPref();
}
}
public void OnMusicMute(bool muteMusic)
{
AudioPlayer.instance.ToggleMusic(muteMusic);
//uiHandleRectTransform.anchoredPosition = muteMusic ? handlePostion * -1: handlePostion;
Save();
}
// public void OnEffectsMute(bool muteEffects)
// {
// PlayerPrefs.SetInt("ToggleEffects", 0);
// }
void LoadMusicPref()
{
muteMusic = PlayerPrefs.GetInt("muteMusic") == 1;
}
void Save()
{
Debug.Log("muteMusic is set to:" + muteMusic);
PlayerPrefs.SetInt("muteMusic", muteMusic ? 1 : 0);
}
}