天津23维预案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

105 lines
2.3 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UI_FourFireController : MonoBehaviour {
Button btnShow;
Button btnHide;
// public static UI_FourFireController Instance;
[HideInInspector]
public GameObject objParticle;
private void Awake()
{
// Instance = this;
}
// Use this for initialization
void Start() {
btnShow = transform.Find("btn_Open").GetComponent<Button>();
btnHide = transform.Find("btn_Hide").GetComponent<Button>();
btnShow.onClick.AddListener(Open);
btnHide.onClick.AddListener(Hide);
}
public void SetParticle(GameObject obj)
{
objParticle = obj;
}
void Open()
{
if (objParticle == null)
{
Debug.Log("粒子为空");
return;
}
int childCount = objParticle.transform.childCount;
Transform transChild;
for (int i = 0; i < childCount; i++)
{
transChild = objParticle.transform.GetChild(i);
if (transChild.gameObject.activeInHierarchy|| transChild.name.Contains("text"))
{
continue;
}
else
{
transChild.gameObject.SetActive(true);
}
}
Destroy(gameObject);
}
void Hide()
{
if (objParticle == null)
{
Debug.Log("粒子为空");
return;
}
int childCount = objParticle.transform.childCount;
Transform transChild;
for (int i = 0; i < childCount; i++)
{
transChild = objParticle.transform.GetChild(i);
if (!transChild.gameObject.activeInHierarchy || transChild.name.Contains("text"))
{
continue;
}
else
{
transChild.gameObject.SetActive(false);
}
}
Destroy(gameObject);
}
float ShowTimer = 4f;
private void Update()
{
if (ShowTimer > 0)
{
ShowTimer -= Time.deltaTime;
}
else {
Destroy(gameObject);
}
}
//private void OnDestroy()
//{
// Instance = null;
// objParticle = null;
//}
}