123 lines
2.6 KiB
C#
123 lines
2.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Transfercontract : MonoBehaviour
|
|
{
|
|
|
|
/// <summary>
|
|
/// 显示页面存起来
|
|
/// </summary>
|
|
public List<GameObject> switchpowersupplys = new List<GameObject>();
|
|
|
|
/// <summary>
|
|
/// 点击显示对应的页面
|
|
/// </summary>
|
|
public List<Toggle> switchptoggles = new List<Toggle>();
|
|
/// <summary>
|
|
/// 上一页按钮
|
|
/// </summary>
|
|
public Button previous2button;
|
|
/// <summary>
|
|
/// 显示当前第几页
|
|
/// </summary>
|
|
public Text numberofpages2test;
|
|
/// <summary>
|
|
/// 下一页按钮
|
|
/// </summary>
|
|
public Button next2button;
|
|
public Image[] inhabitants;
|
|
///// <summary>
|
|
///// 获取生成对象的位置
|
|
///// </summary>
|
|
public ScrollRect scrollRect;
|
|
/// <summary>
|
|
/// 用户图片
|
|
/// </summary>
|
|
private int pageNum = 0;
|
|
/// <summary>
|
|
/// 获取对应的对象
|
|
/// </summary>
|
|
private GameObject currentOpenObj;
|
|
private Toggle currentOpenToggle;
|
|
|
|
public int PageNum
|
|
{
|
|
get => pageNum;
|
|
set
|
|
{
|
|
currentOpenObj.SetActive(false);
|
|
pageNum = value;
|
|
UpdatePanel();
|
|
}
|
|
}
|
|
|
|
private void UpdatePanel()
|
|
{
|
|
switchpowersupplys[pageNum].SetActive(true);
|
|
currentOpenObj = switchpowersupplys[pageNum];
|
|
numberofpages2test.text = (pageNum + 1).ToString();
|
|
Debug.Log("打印一遍");
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
for (int i = 0; i < switchptoggles.Count; i++)
|
|
{
|
|
int index = i;
|
|
switchptoggles[index].onValueChanged.AddListener((ison) =>
|
|
{
|
|
|
|
PageNum = index;
|
|
});
|
|
}
|
|
currentOpenObj = switchpowersupplys[0];
|
|
|
|
previous2button.onClick.AddListener(Previous2);
|
|
next2button.onClick.AddListener(Nextpage2);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 点击上一页
|
|
/// </summary>
|
|
public void Previous2()
|
|
{
|
|
if (PageNum != 0)
|
|
{
|
|
switchptoggles[PageNum - 1].isOn = true;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 点击下一页
|
|
/// </summary>
|
|
public void Nextpage2()
|
|
{
|
|
if (PageNum != (switchpowersupplys.Count - 1))
|
|
{
|
|
switchptoggles[PageNum + 1].isOn = true;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 还原合同刚开始页面
|
|
/// </summary>
|
|
public void Restore(int index)
|
|
{
|
|
PageNum = index;
|
|
switchptoggles[PageNum].isOn = true;
|
|
scrollRect.verticalNormalizedPosition = 1;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|