87 lines
1.4 KiB
C#
87 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
using UnityEngine.Events;
|
|
|
|
public class Button_click_count : MonoBehaviour
|
|
{
|
|
public string[] 关闭物体;
|
|
public string[] 开启物体;
|
|
|
|
public string[] 触发方法;
|
|
|
|
|
|
[SerializeField]
|
|
private UnityEvent events;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
GetComponent<Button>().onClick.AddListener(onclick);
|
|
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void Fangfa() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
public void onclick() {
|
|
|
|
events?.Invoke();
|
|
GameObject[] gameObjects = Resources.FindObjectsOfTypeAll<GameObject>();
|
|
|
|
|
|
for (int i = 0; i < 关闭物体.Length; i++)
|
|
{
|
|
for (int g = 0; g < gameObjects.Length; g++)
|
|
{
|
|
|
|
if (gameObjects[g].name == 关闭物体[i])
|
|
{
|
|
|
|
|
|
gameObjects[g].SetActive(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
for (int i = 0; i < 开启物体.Length; i++)
|
|
{
|
|
for (int g = 0; g < gameObjects.Length; g++)
|
|
{
|
|
|
|
if (gameObjects[g].name == 开启物体[i])
|
|
{
|
|
|
|
|
|
gameObjects[g].SetActive(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|