File tree 2 files changed +696
-0
lines changed
2 files changed +696
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System . Collections ;
2
+ using System . Collections . Generic ;
3
+ using UnityEngine ;
4
+
5
+ //Uses singleton pattern
6
+ public class Particle_System_Script : MonoBehaviour
7
+ {
8
+ public static Particle_System_Script Instance ;
9
+ public ParticleSystem current_ParticleSystem ;
10
+ public Transform current_TransPos ;
11
+
12
+
13
+ void Awake ( )
14
+ {
15
+ //Check if there is already an instance of
16
+ if ( Instance == null )
17
+ {
18
+ //if not, set it to this.
19
+ Instance = this ;
20
+ DontDestroyOnLoad ( gameObject ) ;
21
+
22
+ }
23
+ //If instance already exists:
24
+ else if ( Instance != this && Instance != null )
25
+ {
26
+ //Destroy this, this enforces our singleton pattern.
27
+ Destroy ( gameObject ) ;
28
+ }
29
+ }
30
+
31
+
32
+ void Start ( )
33
+ {
34
+
35
+ }
36
+
37
+ //Set the instance to null ondestroy
38
+ void OnDestroy ( )
39
+ {
40
+ if ( Instance == this )
41
+ {
42
+ Instance = null ;
43
+ }
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments