Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

5.4.0b7 This playable is invalid

Discussion in '5.4 Beta' started by freekstorm, Mar 2, 2016.

  1. freekstorm

    freekstorm

    Joined:
    Nov 11, 2010
    Posts:
    86
    Code (csharp):
    1. clipPlayable = AnimationClipPlayable.Create(selectedClip);
    2. m_Mixer.SetInput(clipPlayable, 1);


    results in the error:

    InvalidOperationException: This playable is invalid. To create a valid playable, please use the Create method for your playable type

    clipPlayable and m_Mixer are valid before the SetInput call. Has there been an update to the way this works?
     
    MrEsquire likes this.
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    Can I get a bigger code sample?
    From this limited sample, this should work.

    If you submit a bug report with your sample (and paste the bug # here) I'll be happy to take a look at it right now.
     
    Last edited: Mar 2, 2016
  3. freekstorm

    freekstorm

    Joined:
    Nov 11, 2010
    Posts:
    86
    The project is way to big to submit.
    But the code is not complex
    Code (csharp):
    1.  
    2.     AnimationClip selectedClip = clip;
    3.  
    4.  
    5.  
    6.        AnimatorControllerPlayable controllerPlayable = AnimatorControllerPlayable.Create(GetComponent<Animator>().runtimeAnimatorController);
    7.         clipPlayable = AnimationClipPlayable.Create(selectedClip);
    8.         m_Mixer = new AnimationMixerPlayable();
    9.         //m_Mixer.SetInputs(new [] { clip1, clip2 });
    10.         m_Mixer.SetInputs(new Playable[] { clipPlayable });
    11.         // Bind the playable graph to the player
    12.         GetComponent<Animator>().Play(m_Mixer);
    13.  
    This worked in 5.3.0
     
  4. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    Ah, yes.
    The API has changed in 5.4 to improve performance, and the playables (in C#) are now handles (implemented with structs) to their C++ counterparts.
    You need to use the .Create() method to create all your playables, as the error message is telling you.

    m_Mixer = AnimationMixerPlayable.Create().

    Sadly, we can't prevent using the constructor, because structs always have a default constructor defined, that can't be overridden. And we need to use structs to avoid allocating memory each time a playable is connected and disconnected
     
  5. freekstorm

    freekstorm

    Joined:
    Nov 11, 2010
    Posts:
    86
    Awesome, all working now. Thank you.
    Do you know if this will move out of experimental in 5.4 ( so I don't get caught out)
     
  6. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    No, it will stay in experimental until at least 5.5.
    We expect new changes to the API again in 5.5 to make it more user friendly.