using UnityEngine; using System.Collections; public class setAnimationEvent : MonoBehaviour { public RuntimeAnimatorController m_runtimeAnimatorController; // Use this for initialization void Start () { m_runtimeAnimatorController = this.GetComponent<Animator>().runtimeAnimatorController; AnimationEvent newEvent = new AnimationEvent(); newEvent.functionName = "print"; newEvent.time = 0.2f; m_runtimeAnimatorController.animationClips[0].AddEvent(newEvent); Debug.Log(m_runtimeAnimatorController.animationClips.Length.ToString()); this.GetComponent<Animator>().Rebind(); } // Update is called once per frame void Update () { } void print() { Debug.Log("ssss"); } }