AnimationEvent has strange behaviour. When I’m trying to change parameter (int, object…) in foreach block it changes parameter value for current clipEvent but it doesn’t change parameter value for animationClip.events_! So I can suppose that IEnumerator returns reference to copy of the event which is instance of class. It looks like unexpected behaviour. Am I wrong?_
[spoiler]
```csharp
*namespace UnityEngine
{
[RequiredByNativeCode]
public sealed class AnimationEvent
{
public AnimationEvent();
…
// Int parameter that is stored in the event and will be sent to the function.
public int intParameter { get; set; }
// Object reference parameter that is stored in the event and will be sent to the
// function.
public Object objectReferenceParameter { get; set; }
...
}
}*
* *[/spoiler]* *However I'm tried to change parameter through direct reference to event. As you can see setter of AnimationEvent is public. But parameter didn't change.* *
csharp
*public class ChangeAnimationEventParameter : MonoBehaviour
{
[SerializeField] AnimationClip animationClip = null;
void Start()
{
foreach (var clipEvent in animationClip.events.Where(@event => @event.functionName.Equals("OnEvent")))
{
//clipEvent.intParameter equals 0 at start
clipEvent.intParameter = 1;
Debug.Log(animationClip.events[0].intParameter + " "+clipEvent.intParameter);
}
animationClip.events[0].intParameter = 2;
Debug.Log(animationClip.events[0].intParameter);
}
}
//DEBUG LOG
//0 1
//0*
```