Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

how do you reference an object in the scene from a TimelineBehaviour

Discussion in 'Timeline' started by laurentlavigne, Mar 18, 2021.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,293
    I use this
    and it's not showing any scene object in the reference
    upload_2021-3-17_17-6-32.png
    it's also not letting me access in scene statics except
    public static ClassName instance
    but not the stuff that's in it.
    i understand that timelines are assets so that's why there is a whole binding thing happening but then how do i get timeline behavior to bind in-scene objects?

    Code (CSharp):
    1. using System;
    2. using UltEvents;
    3. using UnityEngine;
    4. using UnityEngine.Playables;
    5.  
    6. public class TimelineUltEvents : PlayableAsset
    7. {
    8.     #if UNITY_EDITOR
    9.     [Multiline] public string comment;
    10.     #endif
    11.     public UltEvent actions;
    12.     public Action actionsUnity;
    13.  
    14.     public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    15.     {
    16.         var playable = ScriptPlayable<TimelineUltEventsBehaviour>.Create(graph);
    17.         var sceneActivateBehaviour = playable.GetBehaviour();
    18.         sceneActivateBehaviour.actions = actions;
    19.         sceneActivateBehaviour.actionsUnity = actionsUnity;
    20.         return playable;
    21.     }
    22. }
    23. public class TimelineUltEventsBehaviour : PlayableBehaviour
    24. {
    25.     public UltEvent actions;
    26.     public Action actionsUnity;
    27.  
    28.     public override void OnBehaviourPlay(Playable playable, FrameData info)
    29.     {
    30.         actions?.Invoke();
    31.         actionsUnity?.Invoke();
    32.     }
    33. }