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

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:
    295
    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.
     
  3. Onworlds

    Onworlds

    Joined:
    Feb 19, 2015
    Posts:
    7
    @simonbz
    I hate that reflection GC Alloc.
    When will that method change public?
    I think it is very easy fix.