-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingManger.cs
71 lines (62 loc) · 1.94 KB
/
SettingManger.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SettingManger : MonoBehaviour
{
public GameObject soundManger = null;
public Slider backVolume;
private float backVol = 1f;
private AudioSource audio;
public Image bgmImage;
private void Start()
{
soundManger = GameObject.Find("SoundManager");
audio = soundManger.GetComponent<AudioSource>();
backVol = PlayerPrefs.GetFloat("backvol", 1f);
backVolume.value = backVol;
audio.volume = backVolume.value;
}
public void OnClickBGM() //끈 상태에서도 BGM조절 가능하도록
{
if (bgmImage.color.a < 0.9) // 1f
{
var tmpColor = bgmImage.color;
bgmImage.color = new Color(tmpColor.r, tmpColor.g, tmpColor.b, 1f);
PlayerPrefs.SetFloat("backvol", 1.0f);
backVolume.value = 1.0f;
backVol = backVolume.value;
Debug.Log("bgmOff");
}
else // 0.3f
{
var tmpColor = bgmImage.color;
bgmImage.color = new Color(tmpColor.r, tmpColor.g, tmpColor.b, 0.3f);
backVolume.value = 0.0f;
backVol = backVolume.value;
PlayerPrefs.SetFloat("backvol", 0.0f);
Debug.Log("bgmOn");
}
}
private void Update()
{
VolumeSlider();
}
public void VolumeSlider()
{
if (backVolume.value != 0.0f)
{
var tmpColor = bgmImage.color;
bgmImage.color = new Color(tmpColor.r, tmpColor.g, tmpColor.b, 1f);
//backVolume.value = 0.0f;
}
else
{
var tmpColor = bgmImage.color;
bgmImage.color = new Color(tmpColor.r, tmpColor.g, tmpColor.b, 0.3f);
}
audio.volume = backVolume.value;
backVol = backVolume.value;
PlayerPrefs.SetFloat("backvol", backVolume.value);
}
}