-
Notifications
You must be signed in to change notification settings - Fork 0
/
SwirlColorer.cs
43 lines (34 loc) · 1.3 KB
/
SwirlColorer.cs
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
/**********************************************************************************
* SwirlColorer.cs - manages runtime assignment of color gradientsto swirl particle
* system. Note new gradient startcolor assignment changes the PS, not the Shader.
* [Seperate class from ObjectAccessor due to issues with maintaining runtime
* references to the particle system.]
*********************************************************************************/
using UnityEngine;
public class SwirlColorer : MonoBehaviour {
public static SwirlColorer Instance = null;
#pragma warning disable 0649
[SerializeField] private Color[] swirlColorsLow;
[Space]
[SerializeField] private Color[] swirlColorsHigh;
#pragma warning restore 0649
private int arg;
private ParticleSystem swirls;
private ParticleSystem.MainModule settings;
void Awake() {
if (Instance == null) {
Instance = this;
}
else {
Destroy(gameObject);
}
}
void Start() {
swirls = GetComponent<ParticleSystem>();
settings = swirls.main;
}
public void SetSwirlColors () {
arg = ObjectAccessor.Instance.SkyBoxIndex;
settings.startColor = new ParticleSystem.MinMaxGradient(swirlColorsLow[arg], swirlColorsHigh[arg]);
}
}