| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- /* 靶子画中画 */
- public class TargetView : MonoBehaviour
- {
- public void Show(bool value)
- {
- this.gameObject.SetActive(value);
- }
- public bool IsOpen()
- {
- return this.gameObject.activeSelf;
- }
- public void ReverseActive()
- {
- this.gameObject.SetActive(!this.gameObject.activeSelf);
- }
- [SerializeField] Button button;
- void RefreshButton()
- {
- Transform icon1 = button.transform.Find("Icon1");
- Transform icon2 = button.transform.Find("Icon2");
- if (IsOpen()) {
- icon1.gameObject.SetActive(false);
- icon2.gameObject.SetActive(true);
- button.transform.Find("Text").gameObject.SetActive(false);
- button.GetComponentInChildren<TextAutoLanguage>()?.SetText(205);
- } else {
- icon1.gameObject.SetActive(true);
- icon2.gameObject.SetActive(false);
- button.transform.Find("Text").gameObject.SetActive(true);
- button.GetComponentInChildren<TextAutoLanguage>().SetText(204);
- }
- }
- void OnEnable()
- {
- RefreshButton();
- }
- void OnDisable()
- {
- RefreshButton();
- }
- void OnDestroy()
- {
- if (_ins == null) _ins = null;
- }
-
- private static TargetView _ins = null;
- public static TargetView ins {
- get {
- if (_ins == null) {
- _ins = GameObject.Find("Canvas/GameAssistUI/TargetView").GetComponent<TargetView>();
- }
- return _ins;
- }
- }
- }
|