Search Unity

How update the property for a custom IAnimationJob when changed in inspector?

Discussion in 'Animation' started by watsonsong, Dec 27, 2018.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I write a struct custom job with some property like bounciness, stiffness and dampness. Code like this:
    Code (CSharp):
    1.  
    2. public struct MyCustomJob : IAnimationJob
    3. {
    4.     public float Bounciness;
    5.     public float Stiffness;
    6.     public float Dampness;
    7.  
    8.     private NativeArray<TransformStreamHandle> jointHandles;
    9.     private NativeArray<int> jointParents;
    10.     ....
    11. }
    12.  
    When I write a MonoBehaviour, the properties is on the inspector as a serialized field:
    Code (CSharp):
    1.  
    2. [RequireComponent(typeof(Animator))]
    3. public sealed class MyCustomTest : MonoBehaviour
    4. {
    5.     [SerializeField]
    6.     private Transform root;
    7.  
    8.     [SerializeField]
    9.     private float bounciness = 40.0f;
    10.  
    11.     [SerializeField]
    12.     private float stiffness = 1.0f;
    13.  
    14.     [SerializeField]
    15.     private float dampness = 0.1f;
    16.  
    17.     ....
    18. }
    19.  
    I want when the inspector change, in OnValidation can update automaticly. Rightnow I need stop the graph and replay it.