| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- 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);
- }
- }
- private void Start()
- {
- if (GameMgr.HideTargetView) {
- Show(false);
- GameMgr.HideTargetView = false;
- }
- }
- 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;
- }
- }
- }
|