12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using Blue;
- using UnityEngine;
- public class MinMapPos : AbstractController
- {
- [SerializeField] private GameObject MinMapCanvas;
- private bool first = true;
- private IMinMapService minMapService;
- private int value;
- void Start()
- {
- minMapService = this.GetService<IMinMapService>();
- if (MinMapCanvas != null)
- {
- minMapService.setMinMap.Register(
- newValue =>
- {
- //Debug.LogError("新的值:" + newValue);
- value = newValue;
- if (newValue == 0)
- MinMapCanvas.SetActive(false);
- else
- MinMapCanvas.SetActive(true);
- if (first)
- {
- first = false;
- return;
- }
- minMapService.Set();
- }
- ).UnRegisterWhenGameObjectDestroyed(gameObject);
- MinMapCanvas.transform.parent = OpenXRCamera.Instance.head;
- }
- }
- private bool patch = true;
- private void Update()
- {
- //其他地方有引用小地图,控制了开关;统一由IMinMapService控制
- if (value == 0 && patch)
- {
- if (MinMapCanvas.activeSelf == true)
- {
- MinMapCanvas.SetActive(false);
- patch = false;
- }
- }
- }
- }
|