备份CatanBuilding瘦身独立工程
This commit is contained in:
125
Assets/Scripts/UI/InfoPopupPanel/PageInfoPopupPanel.cs
Normal file
125
Assets/Scripts/UI/InfoPopupPanel/PageInfoPopupPanel.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/InfoPopupPanel/PageInfoPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/InfoPopupPanel/PageInfoPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9831ae2116a1d5641bf6b18fc041320b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user