Search Unity

BUG? SignalEmitters on Timeline ALL Change to Keep Last Input Value

Discussion in 'Timeline' started by ippdev, Jan 18, 2021.

  1. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    I want an object to change it's height by the passed in value from the field in The SignalReceiver Reaction like this...
    Code (CSharp):
    1. public void SetRigHeight (float yPosition) {
    2.      wantedRigPos = new Vector3(rig.position.x, rigPosition.y + yPosition, rig.position.z);
    3.      useSetRigHeight = true;
    4. }
    It works fine on the first Signal installed on the Timeline and passes in the value from the UnityEvent Reaction. However if you add a second Signal and try to set the value it will revert all previous Signal to the newest passed in value. I do not think it is supposed to work like that. You should be able to pass in any value and not have it affect any other Signals. On 2019.4.9f1 and using the Timeline 1.5.2 package.
     
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    I'm sorry, I don't understand your question.

    Please include more code as context, or file a bug report so that we can inspect your code directly
     
  3. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    It isn't my code. It is your implementation of Signals. In the UnityEvent invoked from the SignalEmitter on the timeline track if you have a field to pass in a value, this value gets reliably passed into the function. However, if I place a second signal on the timeline and change the value, the new value changes the old value on the first signal. If I place a third signal and change that value it changes the value on the first two signals
     
    Last edited: Jan 20, 2021
  4. julienb

    julienb

    Unity Technologies

    Joined:
    Sep 9, 2016
    Posts:
    177
    In a SignalReceiver, a UnityEvent is associated with a SignalAsset. When you create a SignalEmitter on a timeline, the Inspector shows you the UnityEvent associated with the signal asset. If you re-use the same signal asset with multiple emitters, changing the event will change it for all emitters using this asset.

    See this blog post for more explanations.

    For what you want to do, I see two options:

    - Create multiple signal assets: Use multiple signals assets and, in the receiver, set up the unity event to call the method with the correct arguments.
    Example:
    SignalAsset: "SetRigHeight2" -> UnityEvent: calls SetRigHeight with yPosition=2
    SignalAsset: "SetRigHeight3" -> UnityEvent: calls SetRigHeight with yPosition=3

    - Put a payload in the emitter: It is possible to put values in the emitter itself, much like Animation events. But the signals system doesn't support that and you will need custom code. Fortunately, there is an implementation here.
     
  5. retrobrain_dongyi_cai

    retrobrain_dongyi_cai

    Joined:
    Feb 3, 2021
    Posts:
    10
    Similar issue also happens to me. Once I created a signal in signal track, somehow it reverts back to previous values. I can't reproduce it always so there is no bug report. It looks like UI issue.

    Also maybe related, playable asset in unity is not cleaned up once a script is modified or removed. I do have custom code to pass parameters, (The implementation mentioned above doesn't work due to exception in Editor Inspector, so I have another one). And I noticed that remove the track or remove the signal won't actually remove the monobehaviour section in playable asset (serialized as text, just open text editor to edit it). Also, sometimes somehow somewhat the signals disappears.