Hi,
I’m trying to change an Animation Clip at runtime directly in code.
The “animationClipCopy” is created at runtime and I set its curves manually.
The issue is that setting the runtime animation controller animation clips at runtime does not work.
We can see this by logging the instance ID
Debug.Log(animationClipCopy.GetInstanceID());
Debug.Log( m_RuntimeAnimatorController.animationClips[0].GetInstanceID());
m_RuntimeAnimatorController.animationClips[0] = animationClipCopy;
Debug.Log("After");
Debug.Log(animationClipCopy.GetInstanceID());
Debug.Log( m_RuntimeAnimatorController.animationClips[0].GetInstanceID());
This code results in:
-57100
3980
After
-57100
3980
I was expecting
-57100
3980
After
-57100
-57100
I can’t set m_RuntimeAnimatorController.animationClips array because it is get only and I can’t edit it for some unexplained reason
I want to edit the animation curves at runtime so this is causing me some issues.
So far my code works, but I’m changing the original animationClip instead of the copy. And this is a problem because it saves those changes on the animationClip asset file within the project even after exiting playmode.
My workaround was to add a AnimationOverrideController with dummy animation clip assets in the editor, that don’t matter if changed. But that’s really not ideal since I use the AnimationClip name to fetch the animation clip I want to change.
Any Advice is welcomed