Last active
March 30, 2016 12:57
-
-
Save sisso/8561422 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
#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