PlayableGraph is not cloned when instantiate GameObject

I have created custom PlayableGraph for Animator. When I clone this GameObject (Instantiate) PlayableGraph for cloned Animator is empty (only one AnimationOutput and not my custom graph).

So my question is how can I copy entire PlayableGraph hierarchy to another object?

I have tried some ideas, but many of them are crashing Unity (wrong memory access).

I don’t think you can. There is no copy/clone functionality on Playables or PlayableGraph, and they are not serializable objects (by design).

Thank you for answer.

One more question regarding copying PlayableGraph. I create AnimatorControllerPlayable from RuntimeAnimatorController and right now I have to keep reference to that RuntimeAnimatorController in order to copy PlayableGraph. Is there a method to get that RuntimeAnimatorController directly from created AnimatorControllerPlayable or can it be added?

There is no method exposed for that. I’ll send a request to the animation team, it looks like it would be an easy addition.

Thank you.
It would be good to have exposed method for getting AnimationClip from AnimationClipPlayable too. I’m sure it will be useful for someone.

Looks like there is - AnimationClipPlayable.GetAnimationClip(). Not sure why it’s not documented though.

Just checked, and the documentation is in the process of being updated.

Oh. Didn’t see it. Nice.