151 lines
3.0 KiB
C#
151 lines
3.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public class SheJiShiShiPage : UIPageBtnEventBase
|
|
{
|
|
|
|
public List<GameObject> myPages = new List<GameObject>();
|
|
private void OnEnable()
|
|
{
|
|
enter181 = FindObjectOfType<Enter181Page>();
|
|
}
|
|
|
|
public override void OnF1Click()
|
|
{
|
|
base.OnF1Click();
|
|
OpenPage(0);
|
|
}
|
|
|
|
public override void OnF2Click()
|
|
{
|
|
base.OnF2Click();
|
|
OpenPage(1);
|
|
}
|
|
|
|
|
|
public override void OnF3Click()
|
|
{
|
|
base.OnF3Click();
|
|
|
|
OpenPage(2);
|
|
|
|
}
|
|
|
|
public override void OnF4Click()
|
|
{
|
|
base.OnF4Click();
|
|
|
|
OpenPage(3);
|
|
}
|
|
|
|
public override void OnF5Click()
|
|
{
|
|
|
|
base.OnF5Click();
|
|
enter181.OnShow();
|
|
ResetPage(myPages);
|
|
//gameObject.SetActive(false);
|
|
Debug.Log("desssss");
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
|
|
|
|
void OpenPage(int index)
|
|
{
|
|
if (myPages[currentIndex] != null) //如果有物体被打开,则不执行切换逻辑
|
|
return;
|
|
myPages[index].SetActive(true);
|
|
currentIndex = index;
|
|
}
|
|
|
|
|
|
void OperationByPageNameF1()
|
|
{
|
|
switch (myPages[currentIndex].name)
|
|
{
|
|
case"诸元方式":
|
|
break;
|
|
case "坐标方式":
|
|
break;
|
|
case "射击修正":
|
|
break;
|
|
case "整理成果":
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|