Instantly share code, notes, and snippets.

Embed
What would you like to do?
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