-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugTools.cs
More file actions
49 lines (44 loc) · 924 Bytes
/
DebugTools.cs
File metadata and controls
49 lines (44 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class DebugTools : MonoBehaviour
{
List<GameObject> CacheParticleObjects = new List<GameObject>();
void OnGUI()
{
GUI.skin.button.fontSize = 32;
if (CacheParticleObjects.Count > 0)
{
if (GUILayout.Button("恢复粒子"))
EnableParticle();
}
else
{
if (GUILayout.Button("禁用粒子"))
DisableParticle();
}
}
void DisableParticle()
{
CacheParticleObjects.Clear();
var particles = Object.FindObjectsOfType(typeof(ParticleSystem)) as ParticleSystem[];
foreach (var particle in particles)
{
var go = particle.gameObject;
if (go.activeInHierarchy)
{
go.SetActive(false);
CacheParticleObjects.Add(go);
}
}
}
void EnableParticle()
{
foreach (var go in CacheParticleObjects)
{
if (go != null)
go.SetActive(true);
}
CacheParticleObjects.Clear();
}
}