PanelSet.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class PanelSet : MonoBehaviour {
  7. private Button backBtn;
  8. private Slider musicsli;
  9. private Slider audiosli;
  10. // Use this for initialization
  11. void Start () {
  12. backBtn = transform.Find("BackBtn").GetComponent<Button>();
  13. backBtn.onClick.RemoveAllListeners();
  14. backBtn.onClick.AddListener(backBtnEvent);
  15. musicsli = transform.Find("MusicSli").GetComponent<Slider>();
  16. musicsli.value = ScoreManager.instance.BGM;
  17. audiosli = transform.Find("AudioSli").GetComponent<Slider>();
  18. audiosli.value = ScoreManager.instance.AM;
  19. }
  20. private void backBtnEvent()
  21. {
  22. UIManager.instance.CreatePanel("PanelStart");
  23. UIManager.instance.DestroyPanel("PanelSet");
  24. PlayerPrefs.SetFloat("BGM",musicsli.value);
  25. PlayerPrefs.SetFloat("AM",audiosli.value);
  26. }
  27. // Update is called once per frame
  28. void Update () {
  29. ScoreManager.instance.BGM = musicsli.value;
  30. ScoreManager.instance.AM = audiosli.value;
  31. }
  32. }