PiZhuDlg.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using ShadowStudio.Model;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using XRTool.Util;
  8. using XRTool.WorldUI;
  9. namespace ShadowStudio.UI
  10. {
  11. [RequireComponent(typeof(WorldDlg))]
  12. public class PiZhuDlg : UnitySingleton<PiZhuDlg>
  13. {
  14. private Transform piZhuGroupTran;
  15. private ToggleGroup piZhuGroup;
  16. // Start is called before the first frame update
  17. void Start()
  18. {
  19. WorldDlg dlg = GetComponent<WorldDlg>();
  20. piZhuGroupTran = dlg.GetBreadthChild<Transform>("PiZhuGroup");
  21. piZhuGroup = dlg.GetBreadthChild<ToggleGroup>("PiZhuGroup");
  22. Toggle[] toggles = piZhuGroupTran.GetComponentsInChildren<Toggle>(true);
  23. for (int i = 0; i < toggles.Length; i++)
  24. {
  25. Toggle toggle = toggles[i];
  26. toggles[i].onValueChanged.AddListener((bool isOn) => { OnToggle(isOn, toggle); });
  27. }
  28. }
  29. private void OnToggle(bool isOn, Toggle toggle)
  30. {
  31. if (isOn)
  32. {
  33. switch (toggle.name)
  34. {
  35. case "Up":
  36. NotePadComponent.CreateLocalNotePad();
  37. //Debug.Log(toggle.name);
  38. break;
  39. case "Down":
  40. Debug.Log(toggle.name);
  41. break;
  42. case "Left":
  43. Debug.Log(toggle.name);
  44. break;
  45. case "Right":
  46. Debug.Log(toggle.name);
  47. break;
  48. case "RightUp":
  49. Debug.Log(toggle.name);
  50. break;
  51. }
  52. }
  53. if (!piZhuGroup.AnyTogglesOn())
  54. {
  55. gameObject.SetActive(false);
  56. }
  57. }
  58. }
  59. }