AnimationClip animClip = new AnimationClip(); AnimationEvent animEvent = new AnimationEvent(); animEvent.time = 1.5f; animEvent.functionName = "PlaySoundEffect"; animClip.AddEvent(animEvent);
AnimationClip animClip = new AnimationClip(); AnimationEvent animEvent = new AnimationEvent(); animEvent.time = 2.0f; animEvent.functionName = "ChangeColor"; animEvent.intParameter = 1; // red color animClip.AddEvent(animEvent);In this example, we add an AnimationEvent to change the color of an object at 2 seconds in the clip. The ChangeColor method will be called with an integer parameter of 1, which represents the color red. This code is part of the UnityEngine package/library.