-
Notifications
You must be signed in to change notification settings - Fork 0
/
SoundManager4.cs
63 lines (55 loc) · 1.9 KB
/
SoundManager4.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace YourNamespace1
{
public class SoundManager4 : MonoBehaviour
{
[SerializeField] Image soundOnIcon; //I'm using serialized fields to constantly update sound on/off icons
[SerializeField] Image soundOffIcon; //I'm using serialized fields to constantly update sound on/off icons
public static bool candleStick = false;
//I'm calling the awake function
void Awake()
{
//UpdateButtonIcon();
}
//I'm calling the start function
void Start()
{
//Not needed anything here
}
//I'm calling the update function
void Update()
{
//Not needed anything here
}
//I'm calling this method when the action is performed
public void OnButtonpress()
{
//I'm toggling the Checkmark variable (for testing purposes)
GlobalVariables1.newCheckmark = !GlobalVariables1.newCheckmark;
//I'm updating the button icons
UpdateButtonIcon();
}
private void UpdateButtonIcon()
{
if (GlobalVariables1.newCheckmark)
{
soundOnIcon.enabled = false;
soundOffIcon.enabled = true;
Debug.Log("Sound Icon has changed to false.");
candleStick = false; //If candleStick = false, no sound
}
else
{
soundOnIcon.enabled = true;
soundOffIcon.enabled = false;
Debug.Log("Sound Icon has changed to true.");
candleStick = true; //If candleStick = true, sound
}
//I'm forcing a UI Update
Canvas.ForceUpdateCanvases();
}
}
}