Scene1Ctrl.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using UnityEngine;
  2. using UnityEngine.SceneManagement;
  3. public class Scene1Ctrl : MonoBehaviour
  4. {
  5. public LatticeButton m_defaultSelectBtn;
  6. public LatticeButton m_level2DefaultSelectBtn;
  7. public GameObject m_level2Obj;
  8. public LatticeButton m_deleteLevel1Btn;
  9. public LatticeButton m_deleteLevel2Btn;
  10. public LatticeButton m_backBtn;
  11. public void OnDoubleTapCallBack()
  12. {
  13. CloseLevel2();
  14. }
  15. void Start()
  16. {
  17. LatticeBrain.FocusLevel(m_defaultSelectBtn.level);
  18. LatticeBrain.SelectButton(m_defaultSelectBtn);
  19. LatticeBrain.Brain.OnDoubleTap += OnDoubleTapCallBack;
  20. m_defaultSelectBtn.onClick.AddListener(OnClick);
  21. m_level2DefaultSelectBtn.onClick.AddListener(CloseLevel2);
  22. m_deleteLevel1Btn.onClick.AddListener(DeleteLevel1);
  23. m_deleteLevel2Btn.onClick.AddListener(DeleteLevel2);
  24. m_backBtn.onClick.AddListener(BackToMainScene);
  25. }
  26. private void BackToMainScene()
  27. {
  28. SceneManager.LoadScene("SampleMain");
  29. }
  30. private void DeleteLevel1()
  31. {
  32. LatticeBrain.RemoveButton(m_deleteLevel1Btn);
  33. }
  34. private void DeleteLevel2()
  35. {
  36. LatticeBrain.RemoveButton(m_deleteLevel2Btn);
  37. }
  38. private void CloseLevel2()
  39. {
  40. m_level2Obj.SetActive(false);
  41. LatticeBrain.FocusLevel(m_defaultSelectBtn.level);
  42. }
  43. private void OnClick()
  44. {
  45. m_level2Obj.SetActive(true);
  46. LatticeBrain.SelectButton(m_level2DefaultSelectBtn, true);
  47. }
  48. // Update is called once per frame
  49. void Update()
  50. {
  51. }
  52. }