using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using HighlightingSystem;
public class Layer1 : ClassRoot { public List btn1_list;
public Texture2D white1_texture2d;
public Texture2D blue1_texture2d;
public List<Button> btn2_list;
public Texture2D white2_texture2d;
public Texture2D blue2_texture2d;
public Animator ani;
public List<Camera> camera_list;
public List<Camera> camera_1_list;
public List<HighlighterConstant> curHig_list;
public List<HighlighterConstant> curHig1_list;
public List<HighlighterConstant> curHig2_list;
private int btnIdx1 = -1;
private int btnIdx2 = -1;
//cqy
public Animator ani1;
public GameObject shujufenxi;
public GameObject shebeishuju;
// Start is called before the first frame update
void Start()
{
//设置相机 开始场景
for (int i = 0; i < btn1_list.Count; i++)
{
int a = i;
btn1_list[i].onClick.AddListener(delegate () { OnClick1(a); });
}
for (int i = 0; i < btn2_list.Count; i++)
{
int b = i;
btn2_list[i].onClick.AddListener(delegate () { OnClick2(b); });
}
OpenOrClose(curHig_list);
OpenOrClose(curHig1_list);
OpenOrClose(curHig2_list);
shujufenxi.SetActive(false);
shebeishuju.SetActive(false);
}
private void OnEnable()
{
//OnClick1(0);
StartCoroutine(MoveEffct(btn1_list));
StartCoroutine(MoveEffct(btn2_list));
camera_list[0].gameObject.SetActive(true);
camera_list[10].gameObject.SetActive(false);
}
// Update is called once per frame
void Update()
{
}
private void OnClick1(int _index)
{
if (btnIdx1 >= 0)
{
ChangeButtonUI(btn1_list[btnIdx1], white1_texture2d);
camera_list[btnIdx1].gameObject.SetActive(false);
}
if (btnIdx2 >= 0)
{
ChangeButtonUI(btn2_list[btnIdx2], white2_texture2d);
}
ChangeButtonUI(btn1_list[_index], blue1_texture2d);
camera_list[_index].gameObject.SetActive(true);
btnIdx1 = _index;
shujufenxi.SetActive(true);
shebeishuju.SetActive(false);
ani.Rebind();
}
private void OnClick2(int _index)
{
//点击下面按钮时 上面按钮变为蓝色
if (btnIdx1 >= 0)
{
camera_list[btnIdx1].gameObject.SetActive(false);
ChangeButtonUI(btn1_list[btnIdx1], white1_texture2d);
}
if (btnIdx2 >= 0)
{
ChangeButtonUI(btn2_list[btnIdx2], white2_texture2d);
}
//设置相机 点击下排按钮时的场景
for (int i = 0; i < camera_1_list.Count; i++)
{
camera_1_list[i].gameObject.SetActive(false);
}
camera_list[10].gameObject.SetActive(true);
ChangeButtonUI(btn2_list[_index], blue2_texture2d);
btnIdx2 = _index;
Open(_index);
shujufenxi.SetActive(false);
shebeishuju.SetActive(true);
ani1.Rebind();
}
private void OnDisable()
{
if (btnIdx1 >= 0)
{
ChangeButtonUI(btn1_list[btnIdx1], white1_texture2d);
btn1_list[btnIdx1].GetComponent<Image>().fillAmount = 0.0f;
}
if (btnIdx2 >= 0)
{
ChangeButtonUI(btn2_list[btnIdx2], white2_texture2d);
btn2_list[btnIdx2].GetComponent<Image>().fillAmount = 0.0f;
}
shujufenxi.SetActive(false);
shebeishuju.SetActive(false);
btnIdx1 = -1;
btnIdx2 = -1;
Open(-1);
}
private void Open(int _index)
{
if (_index == 1)
{
OpenOrClose(curHig_list, true);
OpenOrClose(curHig1_list);
OpenOrClose(curHig2_list);
}
else if (_index == 2)
{
OpenOrClose(curHig_list);
OpenOrClose(curHig1_list, true);
OpenOrClose(curHig2_list);
}
else if (_index == 5)
{
OpenOrClose(curHig_list);
OpenOrClose(curHig1_list);
OpenOrClose(curHig2_list, true);
}
else
{
OpenOrClose(curHig_list);
OpenOrClose(curHig1_list);
OpenOrClose(curHig2_list);
}
}
}
|