50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
//============================================================
|
||
//支持中文,文件使用UTF-8编码
|
||
//@author YangHua
|
||
//@create 20230913
|
||
//@company Adam
|
||
//
|
||
//@description:底部按钮控制器
|
||
//============================================================
|
||
namespace Adam
|
||
{
|
||
public class BottomController : MonoBehaviour
|
||
{
|
||
public Toggle[] toggles;
|
||
public GameObject[] panels;
|
||
public GameObject buttomPanel;
|
||
public Toggle BirdEyeView;
|
||
public FirstPersonController firstPersonController;
|
||
// Use this for initialization
|
||
private void Start()
|
||
{
|
||
for (int i = 0; i < panels.Length; i++)
|
||
{
|
||
panels[i].SetActive(false);
|
||
}
|
||
for (int i = 0; i < toggles.Length; i++)
|
||
{
|
||
int index = i;
|
||
toggles[index].onValueChanged.AddListener((isOn) =>
|
||
{
|
||
panels[index].SetActive(isOn);
|
||
if (firstPersonController == null)
|
||
firstPersonController = GameObject.FindGameObjectWithTag("Player").GetComponent<FirstPersonController>();
|
||
firstPersonController.enabled = !isOn;
|
||
});
|
||
}
|
||
SwitchPanel(false);
|
||
BirdEyeView.gameObject.SetActive(false);
|
||
}
|
||
|
||
public void SwitchPanel(bool isActive)
|
||
{
|
||
buttomPanel.SetActive(isActive);
|
||
}
|
||
}
|
||
}
|