using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShowDifferentPage : MonoBehaviour {
public List<GameObject> pages = new List<GameObject>();
//public GameObject ss;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void ShangePageByPageName(string _name)
{
for (int i=0;i<pages.Count;i++)
{
if (pages[i].name == _name)
{
ChangePageTo(i+1);
return;
}
}
}
public void ChangePageTo(int _pageNum)
{
//Debug.Log(_pageNum.ToString() + " "+pages.Count.ToString());
if (_pageNum > 0 && _pageNum <= pages.Count)
{
for (int i = 0; i < pages.Count; i++)
{
if (_pageNum - 1 == i)
{
pages[i].SetActive(true);
}
else
{
pages[i].SetActive(false);
}
}
}
else
{
return;
}
}
public void TwoPageChangeToAnother()
{
if (pages.Count == 2)
{
if (pages[0].activeSelf == true)
{
pages[0].SetActive(false);
pages[1].SetActive(true);
}
else
{
pages[1].SetActive(false);
pages[0].SetActive(true);
}
}
else
{
Debug.Log("两个页面没有切换");
return;
}
}
public void Exit()
{
Application.Quit();
}
public void CloseAllPages()
{
foreach (GameObject go in pages)
{
go.SetActive(false);
}
}
public void AddChangePage()
{
for (int i=0;i<pages.Count;i++)
{
if (pages[i].activeInHierarchy==true)
{
int nextPage = i + 2;
if (nextPage != pages.Count+1)
{
ChangePageTo(nextPage);
return;
}
else
{
ChangePageTo(1);
return;
}
}
}
}
public void ReduceChangePage()
{
for (int i = 0; i < pages.Count; i++)
{
if (pages[i].activeInHierarchy == true)
{
int nextPage = i ;
if (nextPage != 0)
{
ChangePageTo(nextPage);
return;
}
else
{
ChangePageTo(pages.Count);
return;
}
}
}
}
}