NG_/Assets/Scripts/UI/全局/ShowHidden.cs

73 lines
1.9 KiB
C#
Raw Normal View History

2024-12-13 19:40:05 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class ShowHidden : MonoBehaviour,IPointerClickHandler
{
/*public List<GameObject> hideList;*/
public List<GameObject> showGameObjects;
public List<GameObject> hideGameObjects;
public GameObject showGameObjectParent;
public GameObject hideGameObjectParent;
public List<GameObject> adaptionGameObject;
// Start is called before the first frame update
public void OnPointerClick(PointerEventData eventData)
{
if (UIMove.isStaticMove)
{
return;
}
if (CameraMove.isStaticMove)
{
return;
}
for (int i = 0; i < hideGameObjects.Count; i++)
{
hideGameObjects[i].SetActive(false);
}
if (hideGameObjectParent != null)
{
foreach (Transform hideGameObject in hideGameObjectParent.transform)
{
hideGameObject.gameObject.SetActive(false);
}
}
if (showGameObjectParent!=null)
{
foreach (Transform showGameObject in showGameObjectParent.transform)
{
showGameObject.gameObject.SetActive(true);
}
}
for (int i = 0; i < showGameObjects.Count; i++)
{
showGameObjects[i].SetActive(true);
}
for (int i = 0; i < adaptionGameObject.Count; i++)
{
adaptionGameObject[i].SetActive(!adaptionGameObject[i].activeSelf);
}
}
public void OnMouseDown()
{
PointerEventData pointerData = new PointerEventData(EventSystem.current)
{
pointerPress = gameObject,
pointerCurrentRaycast = new RaycastResult()
};
OnPointerClick(pointerData);
}
}