Skip to content

Commit c42a3f1

Browse files
author
Bharath Vishal G
committed
Commit 1.0.
Added Scripts.
1 parent 82c5e27 commit c42a3f1

File tree

2 files changed

+696
-0
lines changed

2 files changed

+696
-0
lines changed

Scripts/Particle_System_Script.cs

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
}

0 commit comments

Comments
 (0)