summaryrefslogtreecommitdiff
path: root/GameCode/Background.cs
blob: 0b694c79fa49bf976f20f93f37578d9afa6c38e5 (plain)
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
using UnityEngine;

public class Background : MonoBehaviour
{
	private ParticleSystem[] parts;

	private bool hasBeenInitiated;

	private void Init()
	{
		parts = GetComponentsInChildren<ParticleSystem>();
		hasBeenInitiated = true;
	}

	public void ToggleBackground(bool on)
	{
		if (!hasBeenInitiated)
		{
			Init();
		}
		for (int i = 0; i < parts.Length; i++)
		{
			if (on)
			{
				parts[i].Play();
			}
			else
			{
				parts[i].Stop();
			}
		}
	}
}