Skip to content

Instantly share code, notes, and snippets.

@sisso
Last active August 29, 2015 14:17
Show Gist options
  • Save sisso/141f860591a553e71119 to your computer and use it in GitHub Desktop.
Save sisso/141f860591a553e71119 to your computer and use it in GitHub Desktop.
#pragma strict
class AnimatorInputCfg {
var key: KeyCode;
var trigger: String;
};
var commands: AnimatorInputCfg[] = [];
var animator: Animator;
function Start() {
if (!animator) animator = GetComponentInChildren.<Animator>();
if (!animator)
{
Debug.LogWarning("Could not found animator for "+this+"!");
GameObject.Destroy(gameObject);
}
}
function Update () {
for (var c in commands) {
if (Input.GetKeyUp(c.key))
{
animator.SetTrigger(c.trigger);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment