Skip to content

Instantly share code, notes, and snippets.

@OutlawGameTools
Last active August 29, 2015 14:16
Show Gist options
  • Save OutlawGameTools/a736d0c5b870c039c839 to your computer and use it in GitHub Desktop.
Save OutlawGameTools/a736d0c5b870c039c839 to your computer and use it in GitHub Desktop.
CS109 - Generic utilities for particles, such as bring particle up to a named layer so it can be seen.
#pragma strict
public var layerName : String = "Foreground"; // the layer in which the particle should be placed
public var orderInLayer : int = -1; // -1 to go behind the parent object, 1 to go in front of it
public var destroyAfterTime : float = 0;
private var pSys : ParticleSystem;
function Start () {
pSys = GetComponent.<ParticleSystem>();
pSys.GetComponent.<Renderer>().sortingLayerName = layerName;
pSys.GetComponent.<Renderer>().sortingOrder = orderInLayer;
if (destroyAfterTime > 0)
Destroy(pSys, pSys.duration + pSys.startLifetime);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment