Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

PlayableGraph is not cloned when instantiate GameObject

Discussion in 'Timeline' started by dwit_mass_creation, Sep 8, 2017.

  1. dwit_mass_creation

    dwit_mass_creation

    Joined:
    Jun 18, 2015
    Posts:
    43
    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).
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    910
    I don't think you can. There is no copy/clone functionality on Playables or PlayableGraph, and they are not serializable objects (by design).
     
  3. dwit_mass_creation

    dwit_mass_creation

    Joined:
    Jun 18, 2015
    Posts:
    43
    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?
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    910
    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.
     
  5. dwit_mass_creation

    dwit_mass_creation

    Joined:
    Jun 18, 2015
    Posts:
    43
    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.
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    910
    Looks like there is - AnimationClipPlayable.GetAnimationClip(). Not sure why it's not documented though.
     
  7. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    910
    Just checked, and the documentation is in the process of being updated.
     
  8. dwit_mass_creation

    dwit_mass_creation

    Joined:
    Jun 18, 2015
    Posts:
    43
    Oh. Didn't see it. Nice.