E_ElecCompetition/Electrical_inspectionCompet.../Assets/Script/UGUI/Button_click_count.cs

91 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;
public class Button_click_count : MonoBehaviour
{
public string[] ;
public string[] ;
// public string[] 触发方法;
/// <summary>
/// 按钮加载以后控制物体开启关闭的方法
/// </summary>
//[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);
}
}
}
}
}