Skip to content

Instantly share code, notes, and snippets.

@sisso
Last active March 30, 2016 12:57
Show Gist options
  • Save sisso/8561422 to your computer and use it in GitHub Desktop.
Save sisso/8561422 to your computer and use it in GitHub Desktop.
#pragma strict
class PlayEffecsOnInputCfg {
var key: KeyCode;
var delay: float;
var effect: GameObject;
var calmTime: float;
var calmTimeTimer = 0f;
};
var commands: PlayEffecsOnInputCfg[] = [];
function Update () {
for (var c in commands) {
if (Input.GetKeyUp(c.key)) {
Run(c);
}
}
}
function Run(c: PlayEffecsOnInputCfg) {
if (Time.time < c.calmTimeTimer) return;
c.calmTimeTimer = Time.time + c.calmTime;
yield WaitForSeconds(c.delay);
var ps = c.effect.GetComponentInChildren.<ParticleSystem>();
if (ps) {
ps.Play();
}
var pe = c.effect.GetComponentInChildren.<ParticleEmitter>();
if (pe) {
pe.Emit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment