Last active
July 28, 2018 19:28
-
-
Save mvenezia/bdb0bda643e0881179fa7dfad5a9c0cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class FogFXManager : MonoBehaviour | |
{ | |
#region Const Member Variables | |
const int NUM_FOG_SYSTEMS = 4; | |
#endregion | |
#region Public Member Variables | |
public ParticleSystem widePrefab; | |
public ParticleSystem tallPrefab; | |
#endregion | |
#region Private Member Variables | |
Camera cam; | |
#endregion | |
void Start() | |
{ | |
cam = Camera.main; | |
GenerateFog(); | |
} | |
//============================== | |
void GenerateFog() | |
{ | |
Vector3 pos = Vector3.zero; | |
Quaternion rot = Quaternion.identity; | |
for(int i = 0; i < NUM_FOG_SYSTEMS; i++) | |
{ | |
switch(i) | |
{ | |
case 0: | |
//top left corner | |
pos = cam.ScreenToWorldPoint(new Vector3(-30f, cam.pixelHeight, 0f)); | |
rot.eulerAngles = new Vector3(0f, 90f, 0f); | |
Instantiate(widePrefab, pos, rot, gameObject.transform); | |
break; | |
case 1: | |
//bottom right | |
pos = cam.ScreenToWorldPoint(new Vector3(cam.pixelWidth + 30f, 0f, 0f)); | |
rot.eulerAngles = new Vector3(0f, -90f, 0f); | |
Instantiate(widePrefab, pos, rot, gameObject.transform); | |
break; | |
case 2: | |
//bottom left | |
pos = cam.ScreenToWorldPoint(new Vector3(0f, -30f, 0f)); | |
rot.eulerAngles = new Vector3(-90f, 0f, 0f); | |
Instantiate(tallPrefab, pos, rot, gameObject.transform); | |
break; | |
case 3: | |
//top right | |
pos = cam.ScreenToWorldPoint(new Vector3(cam.pixelWidth, cam.pixelHeight + 30f, 0f)); | |
rot.eulerAngles = new Vector3(90f, 0f, 0f); | |
Instantiate(tallPrefab, pos, rot, gameObject.transform); | |
break; | |
default: | |
Debug.LogWarning("Out of range index accessed in fogSystems!"); | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment