先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
126 lines
3.4 KiB
C#
126 lines
3.4 KiB
C#
using GameCore;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PageInfoPopupPanel : MonoBehaviour
|
|
{
|
|
const string PageInfoPopupPanelKey = "PageInfoPopupPanel";
|
|
Button btnBack;
|
|
Button btnClose;
|
|
Button btn_left;
|
|
Button btn_right;
|
|
GameObject text_continue;
|
|
GameObject ImageItem;
|
|
List<GameObject> ImageItemList = new List<GameObject>();
|
|
List<GameObject> selectGos = new List<GameObject>();
|
|
|
|
[SerializeField]
|
|
List<GameObject> page = new List<GameObject>();
|
|
int index = 0;
|
|
int allCount = 0;
|
|
private void Awake()
|
|
{
|
|
btnBack = transform.Find("mask").GetComponent<Button>();
|
|
btnClose = transform.Find("btn_close").GetComponent<Button>();
|
|
btn_left = transform.Find("btn_close/btn_left").GetComponent<Button>();
|
|
btn_right = transform.Find("btn_close/btn_right").GetComponent<Button>();
|
|
text_continue = transform.Find("text_continue").gameObject;
|
|
ImageItem = transform.Find("root/Sliding/ImageItem").gameObject;
|
|
ImageItem.SetActive(false);
|
|
allCount = page.Count;
|
|
|
|
InitPanel();
|
|
}
|
|
private void Start()
|
|
{
|
|
btnClose.onClick.AddListener(OnClickClose);
|
|
btn_left.onClick.AddListener(OnLeftClick);
|
|
btn_right.onClick.AddListener(OnRightClick);
|
|
string value = PlayerPrefs.GetString(PageInfoPopupPanelKey, "");
|
|
string gameObjectName = gameObject.name.Split("InfoPopupPanel")[0];
|
|
bool iscontain = value.Contains(gameObjectName);
|
|
if (!iscontain)
|
|
{
|
|
PlayerPrefs.SetString(PageInfoPopupPanelKey, value + gameObjectName);
|
|
}
|
|
btnBack.enabled = !iscontain;
|
|
btnClose.gameObject.SetActive(iscontain);
|
|
text_continue.SetActive(!iscontain);
|
|
btnBack.onClick.AddListener(BackClick);
|
|
SetData();
|
|
}
|
|
void InitPanel()
|
|
{
|
|
int curCount = ImageItemList.Count;
|
|
if (curCount < allCount)
|
|
{
|
|
for (int i = curCount; i < allCount; i++)
|
|
{
|
|
GameObject go = Instantiate(ImageItem, ImageItem.transform.parent);
|
|
go.SetActive(true);
|
|
selectGos.Add(go.transform.Find("Select").gameObject);
|
|
ImageItemList.Add(go);
|
|
}
|
|
}
|
|
else if (curCount > allCount)
|
|
{
|
|
for (int i = allCount; i < curCount; i++)
|
|
{
|
|
ImageItemList[i].SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
void SetSelect()
|
|
{
|
|
for (int i = 0; i < selectGos.Count; i++)
|
|
{
|
|
selectGos[i].SetActive(i == index);
|
|
}
|
|
}
|
|
void OnLeftClick()
|
|
{
|
|
if (index > 0)
|
|
{
|
|
index--;
|
|
SetData();
|
|
}
|
|
}
|
|
|
|
void OnRightClick()
|
|
{
|
|
if (index < allCount - 1)
|
|
{
|
|
index++;
|
|
SetData();
|
|
}
|
|
}
|
|
void BackClick()
|
|
{
|
|
if (index < allCount - 1)
|
|
{
|
|
index++;
|
|
SetData();
|
|
if (index == allCount - 1)
|
|
{
|
|
btnClose.gameObject.SetActive(true);
|
|
text_continue.SetActive(false);
|
|
btnBack.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
void SetData()
|
|
{
|
|
for (int i = 0; i < page.Count; i++)
|
|
{
|
|
page[i].gameObject.SetActive(i == index);
|
|
}
|
|
SetSelect();
|
|
}
|
|
private void OnClickClose()
|
|
{
|
|
UIManager.Instance.DestroyUI(gameObject.name);
|
|
}
|
|
}
|