Search Unity

Question Can we control what field is automatically tracked?

Discussion in 'Animation' started by DragonCoder, Jan 22, 2023.

  1. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,700
    Hi community,

    let's say we have a monobehavior class A and a monobehavior class B. A has a serialized public float value_a.
    Class B has a serialized float value_b and a reference to an instance of A (ref_a).

    B is also marked with "ExecuteInEditMode".
    Finally B has an update method which says:
    ref_a.value_a = value_b;


    Effectively that means when I change value_b in the editor, value_a on the other component is changed as well.

    Now both components are in children of an animator.
    When I record a clip and edit value_b, only a keyframe for value_b is added. Not for value_a.
    How can I swap that?

    Effectively I wish to record the effect of a script on component A and completely ignore what I manually do in component B.
    Is this possible somehow?

    Huge thanks in advance :)

    P.s. of course the real usecase is a bit more meaningful than this.