TargetView.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class TargetView : MonoBehaviour
  6. {
  7. public void Show(bool value)
  8. {
  9. this.gameObject.SetActive(value);
  10. }
  11. public bool IsOpen()
  12. {
  13. return this.gameObject.activeSelf;
  14. }
  15. public void ReverseActive()
  16. {
  17. this.gameObject.SetActive(!this.gameObject.activeSelf);
  18. }
  19. [SerializeField] Button button;
  20. void RefreshButton()
  21. {
  22. Transform icon1 = button.transform.Find("Icon1");
  23. Transform icon2 = button.transform.Find("Icon2");
  24. if (IsOpen()) {
  25. icon1.gameObject.SetActive(false);
  26. icon2.gameObject.SetActive(true);
  27. button.GetComponentInChildren<TextAutoLanguage>().SetText(205);
  28. } else {
  29. icon1.gameObject.SetActive(true);
  30. icon2.gameObject.SetActive(false);
  31. button.GetComponentInChildren<TextAutoLanguage>().SetText(204);
  32. }
  33. }
  34. void OnEnable()
  35. {
  36. RefreshButton();
  37. }
  38. void OnDisable()
  39. {
  40. RefreshButton();
  41. }
  42. void OnDestroy()
  43. {
  44. _ins = null;
  45. }
  46. private static TargetView _ins = null;
  47. public static TargetView ins {
  48. get {
  49. if (_ins == null) {
  50. _ins = GameObject.Find("Canvas/GameAssistUI/TargetView").GetComponent<TargetView>();
  51. }
  52. return _ins;
  53. }
  54. }
  55. }