一共有20页图片。第一页不能有“上一页”按钮,最后一页不能有“下一页”按钮。
状态:20张图只有第一页显示,其他隐藏。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class fanye01 : MonoBehaviour {
public GameObject[] image;
public GameObject R;
public GameObject L;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (image[19].activeSelf)
{
R.SetActive(false);
}
else
{
R.SetActive(true);
}
if (image[0].activeSelf)
{
L.SetActive(false);
}
else
{
L.SetActive(true);
}
}
public void down()
{
for (int i = 0; i < image.Length; i++)
{
if (image[i].activeSelf)
{
image[i].SetActive(false);
image[i + 1].SetActive(true);
return;
}
}
}
public void up()
{
for (int i = 0; i < image.Length; i++)
{
if (image[i].activeSelf)
{
image[i].SetActive(false);
image[i - 1].SetActive(true);
return;
}
}
}
}