fix:代码提初始化
This commit is contained in:
62
Assets/Scripts/UIManager/UIManager.cs
Normal file
62
Assets/Scripts/UIManager/UIManager.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
//public enum UILayer { HUD,Main,Popup}
|
||||
public class UIManager : BaseMgr<UIManager>
|
||||
{
|
||||
//这里面要维护很多数据,基本上所有的覆盖全屏 UI 的对象都要覆盖,涉及到 UI 外面的也会有一些全部使用 public,目前还没有检测空的办法
|
||||
public GameObject mainCamera;
|
||||
public GameObject worker;
|
||||
public GameObject PopUpCanvas;
|
||||
public Transform WorldIcons;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
}
|
||||
public void Start()
|
||||
{
|
||||
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ConvertToWorkerView()
|
||||
{
|
||||
|
||||
mainCamera.SetActive(false);
|
||||
worker.SetActive(true);
|
||||
|
||||
for (int i = 0; i < WorldIcons.childCount; i++)
|
||||
{
|
||||
WorldIcons.GetChild(i).transform.localScale = Vector3.one * 0.5f;//工人视角下重置大小
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void ConvertToFreeView()
|
||||
{
|
||||
mainCamera.SetActive(true);
|
||||
worker.SetActive(false);
|
||||
|
||||
}
|
||||
public void DisplayData(string targetName)
|
||||
{
|
||||
if (PopUpCanvas.transform.Find(targetName) != null)
|
||||
{
|
||||
PopUpCanvas.transform.Find(targetName).gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
public void HideData()
|
||||
{
|
||||
for(int i = 0; i < PopUpCanvas.transform.childCount; i++)
|
||||
{
|
||||
PopUpCanvas.transform.GetChild(i).gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user