HKMBFZ/Assets/Scripts/Szz_Scripts/UI/181/FaSheZhenDiPage.cs

137 lines
3.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
public class FaSheZhenDiPage : UIPageBtnEventBase
{
public List<GameObject> myPages = new List<GameObject>();
public CustomTMPDropdown ;
public CustomTMPInputField ;
public CustomTMPInputField 线;
public GameObject itemPrefab;
public Transform itemParent;
private void OnEnable()
{
enter181 = FindObjectOfType<Enter181Page>();
for (int i = 0; i < myPages.Count; i++)
{
myPages[i].SetActive(false);
}
myPages[0].SetActive(true);
currentIndex = 0;
}
//单炮修正的编辑界面
public override void OnF2Click()
{
base.OnF2Click();
if (currentIndex == 5)
{
if (.text != "" && 线.text != "")
{
GameObject it = Instantiate(itemPrefab, itemParent);
it.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = .options[.value].text;
it.transform.GetChild(1).GetComponent<TextMeshProUGUI>().text = .text;
it.transform.GetChild(2).GetComponent<TextMeshProUGUI>().text = 线.text;
}
}
}
public override void OnF3Click()
{
base.OnF3Click();
//F3是上一页
Previous();
}
public override void OnF4Click()
{
base.OnF4Click();
Next();
}
public override void OnF5Click()
{
base.OnF5Click();
enter181.OnShow();
ResetPage(myPages);
//gameObject.SetActive(false);
Destroy(gameObject);
}
private int currentIndex = 0;
/// <summary>
/// 切换到下一个元素
/// </summary>
public void Next()
{
if (myPages == null || myPages.Count == 0) return;
// 如果是最后一个元素,则不进行操作
if (currentIndex >= myPages.Count - 1) return;
// 隐藏当前元素
if (myPages[currentIndex] != null)
myPages[currentIndex].SetActive(false);
currentIndex++;
// 显示下一个元素
if (myPages[currentIndex] != null)
myPages[currentIndex].SetActive(true);
}
/// <summary>
/// 切换到上一个元素
/// </summary>
public void Previous()
{
if (myPages == null || myPages.Count == 0) return;
// 如果是第一个元素,则不进行操作
if (currentIndex <= 0) return;
// 隐藏当前元素
if (myPages[currentIndex] != null)
myPages[currentIndex].SetActive(false);
currentIndex--;
// 显示上一个元素
if (myPages[currentIndex] != null)
myPages[currentIndex].SetActive(true);
}
public Enter181Page enter181;
void ResetPage(List<GameObject> targets)
{
DeactivateAllObjects(myPages);
}
public void DeactivateAllObjects(List<GameObject> targetObjects)
{
foreach (var obj in targetObjects.Where(obj => obj != null))
{
obj.SetActive(false);
//foreach (Transform child in obj.transform)
//{
// child.gameObject.SetActive(false);
//}
}
}
}