Search Unity

Question How do I correctly disconnect an output from a timeline playble

Discussion in 'Timeline' started by fleity, Sep 30, 2022.

  1. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    I can specify this more clearly, destroying an animationPlayableOutput causes errors in a class called AnimationOutputWeightProcessor because it does not check if the it's m_output reference is null. So my question becomes how to I correctly destroy an AnimationPlayableOutput and it's associated weight processor?
    --

    Hi everyone,

    I have a somewhat unusual usecase (maybe?) in which I use two playable directors which reference the same playable asset but I want each of them to evaluate different types of tracks.

    lets say one does animation tracks and the other playable director does everything else.

    After the playable graph has been built I loop through the outputs and if they are AnimationPlayableOutputs I want to disconnect them from the graph as cleanly as possible. There should be no inputs that would be calculated by the timeline playable, no outputs which clutter the playable graph visualizer.

    currently I do this:
    Code (CSharp):
    1.                     if (outputNode.IsPlayableOutputOfType<AnimationPlayableOutput>())
    2.                     {
    3.                         var animOutput = (AnimationPlayableOutput) outputNode;
    4.                         animOutput.GetSourcePlayable().DisconnectInput(i);
    5.                         animOutput.SetTarget(null);
    6.                         graph.DestroyOutput(outputNode);
    7.                     }
    but graph.Destroy leads to this error

    ArgumentException: The PlayableOutput is invalid. It has either been Disposed or was never created.

    What I want to achieve works without destroying the output, but I would prefer to get rid of it anyway furthermore I could not find a single example of how to destroy a playable output anywhere. I would expect I have to call something like Disconnect(outputPort) on the timeline playable but that does not exist.
     
    Last edited: Oct 4, 2022