60 lines
1.2 KiB
C#
60 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class UpPageManager : MonoBehaviour
|
|
{
|
|
public List<GameObject> pages = new List<GameObject>();
|
|
GameObject currectPage;
|
|
|
|
private void OnEnable()
|
|
{
|
|
FindAnyObjectByType<MyTest>().upPage = gameObject;
|
|
for (int i = 0; i < pages.Count; i++)
|
|
{
|
|
pages[i].SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
FindAnyObjectByType<MyTest>().OnInit(1);
|
|
}
|
|
|
|
|
|
public void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Alpha1))
|
|
{
|
|
ShowPage(0);
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha2))
|
|
{
|
|
ShowPage(1);
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha3))
|
|
{
|
|
ShowPage(2);
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha4))
|
|
{
|
|
ShowPage(3);
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
{
|
|
currectPage.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void ShowPage(int index)
|
|
{
|
|
|
|
for (int i = 0; i < pages.Count; i++)
|
|
{
|
|
pages[i].SetActive(false);
|
|
}
|
|
currectPage = pages[index];
|
|
pages[index].SetActive(true);
|
|
}
|
|
}
|