35 lines
1.1 KiB
C#
Executable File
35 lines
1.1 KiB
C#
Executable File
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
public class Settings : MonoBehaviour
|
|
{
|
|
public static Settings instance;
|
|
public Button btn_toggle_sfx;
|
|
public Button btn_toggle_music;
|
|
|
|
public Sprite sfx_on,sfx_off;
|
|
public Sprite music_on,music_off;
|
|
|
|
public static void Refresh(){
|
|
if(instance!=null){
|
|
instance.RefreshUI();
|
|
}
|
|
}
|
|
|
|
void Start(){
|
|
instance = this;
|
|
RefreshUI();
|
|
btn_toggle_music.onClick.AddListener(AudioManager.instnace.ToggleMusic);
|
|
btn_toggle_music.onClick.AddListener(RefreshUI);
|
|
|
|
btn_toggle_sfx.onClick.AddListener(AudioManager.instnace.ToggleSFX);
|
|
btn_toggle_sfx.onClick.AddListener(RefreshUI);
|
|
}
|
|
|
|
public void RefreshUI(){
|
|
btn_toggle_music.transform.GetChild(0).GetComponent<Image>().sprite = AudioManager.Music_enabled ? music_on : music_off;
|
|
btn_toggle_sfx.transform.GetChild(0).GetComponent<Image>().sprite = AudioManager.SFX_enabled ? sfx_on : sfx_off;
|
|
}
|
|
}
|