Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Is there a way to get job type in AnimationScriptPlayable?

Discussion in 'Animation Previews' started by EthanCS1993, Jul 4, 2020.

  1. EthanCS1993

    EthanCS1993

    Joined:
    Apr 6, 2018
    Posts:
    4
    AnimationScriptPlayable.GetJobData is a genric function, so you have to know its exact job type before you call it. But if we can know its type like this code:
    Code (CSharp):
    1. Type jobType = playable.GetJobType();
    2.  
    Then i can create C# reflection genric method to call GetJobData function and make it return animationjob's object form, and i can happily call some interface implemented in my animationjob.
    It will help me to improve Unity's PlayableGraphVisualizer, for instance, AnimationScriptPlayableNodes can show different color depend on its job type.
     
  2. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    238
    Hi,

    Indeed, I agree this would be very useful to have. Actually, it's already implemented on the `PlayableHandle` but it's internal. You can access the type through reflection for the time being. This API won't change anytime soon, so I wouldn't worry about breaking changes.

    Code (CSharp):
    1. Type jobType = playable.GetHandle().GetJobType();
    Hope this helps.
     
unityunity