Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. If you're a macOS 10.13 High Sierra user take be sure to read this before updating Unity.
    Dismiss Notice
  5. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  7. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Timeline events?

Discussion in 'Timeline' started by Buzzdev, Jun 24, 2017.

  1. delphinius81

    delphinius81

    Joined:
    Mar 6, 2012
    Posts:
    38
    Any ETA on when this bug fix might make it into a patch release?
     
    Ziplock9000 likes this.
  2. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    327

    I take it the Unity event system might need to be modified to accept more arguments or something for it to have an acceptable workflow? If so, I've got a better idea.

    Since that event system can only take a single argument from the editor as it stands now and the Timeline system needs much more information flowing to it than that to act at such a specific place and time, why not do something like author a data block that contains this entire setup the Timeline needs and pass that entire data block as a single argument through Unity events instead? You could have a little statusbar-like area where the required data is grabbed by simply clicking on the animation event icon at a specific place in the Timeline and supply a gameobject and a Timeline Playable etc. to that statusbar input box by dragging and dropping it. That block would then be read from the gameobject and passed around as if it were a file handle or something. Just an idea.
     
    Last edited: Sep 28, 2017
  3. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    88
    What is the ETA for this, even if it's just a rough ETA?
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    195
    Right now we are targeting early-mid 2018 for a timeline event system. We have a few additional constraints we need to consider for it beyond UI, based on other development inside Unity.

    That's pretty far off for users, and in the mean time we have a couple changes in the pipeline to help mitigate the lack of timeline events. The first is a fix for animation events, that should land in a 2017.3 beta soon, and if possible we will back port to a 2017.2 (we are still seeing if that is feasible).

    The second is adding callbacks to the playable director, mainly to notify when a timeline is complete. That is currently under review, and will make 2018.1 - not sure if will make it back to 2017.3.
     
  5. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    327
    @seant_unity

    Would the fix for animation events allow one to setup a 1 frame animation that would execute a script that could pause or stop the currently playing Timeline, execute some kind of action, then resume the Timeline?

    What would the workflow look like to get this behavior?
     
  6. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    27
    Do you have an idea which of the 2017.3 betas will include this fix? I've looked through the release notes up until "b4" but it's not mentioned in there.
     
  7. thierry_unity

    thierry_unity

    Unity Technologies

    Joined:
    Jun 10, 2015
    Posts:
    117
    @mgeorgedeveloper it's indeed on it's way for merge in the main branch right now. Hoepfully it will be available for 2017.3.0b4. The release notes are only updated when the merge actually happened.
     
    edwon and mgeorgedeveloper like this.
  8. Daemonhahn

    Daemonhahn

    Joined:
    Oct 5, 2013
    Posts:
    272
    I dont mean this in a sarcastic way so sorry if it comes across as this, but what exactly is the point of releasing a timeline system without events?

    I mean it seems like the biggest waste of resources ever. Everything it can do can be done with a mecanim state system and just some simple programming (heck even just copy and pasting).

    All this rubbish about it being the headline feature of 2017 and it turns out to be a semi finished cut scene tool and nothing more.

    Why tout it as being a tool that will help designers become more proactive in development when you know deep down that due to the cuts you made right before release, it is now nothing more than a cut scene tool.

    Very unhappy, every time I think "I might subscribe to paid unity" I see what terrible decisions are still being made and think "still no".

    So many years and still the same terrain system? Still no nested prefabs? Some things are very backward here still, and thats why my money wont be going to unity yet. I would have paid for some of the extra services like Unity Teams but the engine is primarily why we come here and until that is the main focus again instead of stretching paychecks from users with all this extra paid ****, I just dont see value for money.
     
  9. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    327
    I can see where you're coming from -- BIG decisions are being made very poorly these days -- but I don't think it's the engineers at Unity Team's fault -- I think the problem is much more deeply rooted!


    It likely comes down to the Unity app becoming a quick cash-grab for some big-wig investor with an exit strategy -- a guy (or group of guys) who don't plan to stick around to see it fail.



    Sad thing is, the Asset Store has become their flagship product these days too, for a similar reason -- and even that isn't being handled well at all.


    The easy-but-hard answer is that investors hierarchically force engineers to prioritize high-profile features (i.e Timeline) and get them out the door as fast as they can, while ignoring the long-term struggles with broken (or completely missing!) features that devs like us have to deal with when we try to use the 'features' we do have. The 'broken' features are dealt with somewhat, but the missing ones are put on the backburner indefinitely since it does Unity's investors no good to undermine the Asset Store, where creative users used to make things to supplement those 'missing' features for them AND make money for Unity big-wig investors on top of that from the 30% cut from anything the user sells!

    Trouble is -- as an Asset Store developer who has made a great creative tool (Snapcam) to thwart some of the issues of moving around Unity scenes -- it is near-impossible for me to make money off of my asset because I have to charge YOU (my developer brethren) more money than I am comfortable with to make anything worthwhile on it due to Unity's 30% cut just to HOST my asset. Lowering this price wouldn't be as much of an issue if there were more customers, but there's NO marketing effort whatsoever on Unity's end, or any attempt to make creative assets like mine (that will genuinely HELP users enjoy THEIR product more) stand out and be more visible to potential customers (so I can safely lower my price). I've got no idea how they think making such a percentage is justified OR a good business strategy -- because, on top of that, it took them literally a MONTH to review it, and it just sits there collecting dust until I find time to market it myself. Even then, I have to compensate for their greed. This leads to devs like me to not want to create (or even share!) their creative tools on the Asset Store because they feel wrong for charging for what their work is actually worth without having to cheat someone (probably in the same boat as me financially) out of their money (in the investors' stead of course!) to get back that chunk of money those guys pretty much stole from us both. In response to this, users generally wait for the sales before they buy our work because they know we Asset Store devs have no choice but to eventually drop our price. -- It should be clear by now: this is just a system begging for disaster.

    Maybe the long-term investors will boot the cash-grabbing ones out of the picture.

    We can only hope. :(
     
  10. magnoswifty

    magnoswifty

    Joined:
    Nov 2, 2016
    Posts:
    1
    Is this thread still the best reference for how to hack events with the Timeline or have people come up with a more robust approach?

    We're using the approach described by @WikkidEdd1 and it does the job but it feels weird to essentially duplicate the functionality of the graph/mixer that makes the underlying timeline playables work but not actually replace it. Perhaps there's a way to prevent it from generating the normal graph and just have a single Playable that does the work instead?
     
  11. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    27
    @WikkidEdd1 that works great for getting hold of exposed references for the clip. Is there is a similar way to access the "track binding" object within the property drawer? You know, the main output object on the left of the track that is exposed to the track mixer?
     
  12. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    27
    (EDIT: further down is an updated post with a Unity package.)

    By combining techniques given on this and other threads with a healthy dose of reflection and some delegates stuff, I've managed to come up with a fairly robust events system that works as shown in the image.

    (It's actually really simple, but all the damned lines in the image makes it look overly complicated.)

    In short:
    - Add a "Timeline Events" track (or more than one if you want)
    - Add some clips on the track.
    - Associate any GameObject with any clip (optional on a clip to clip basis).
    - Call event handlers at the start and end of each clip, targeting....
    - ....the associated GameObject per clip
    - ....the track's GameObject (track binding on the left).

    Notes:
    - Event handlers are populated via reflection.
    - Event handlers are invoked via delegates at runtime.

    Pending some further testing, I will make the code available if anyone will find this useful.
    Let me know your thoughts.

    [​IMG]
     
    Last edited: Dec 8, 2017
  13. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    327
    Looks very nice -- thanks for the color-coding too!

    I think I speak for everyone when I say it would be much appreciated if you released this. Lots of us don't have time to dig into this right now to roll our own solution and reinvent the wheel, so anything you would be willing to share with us, it's just that much of a leg up we'd have until Unity 'fixes' this issue one day arbitrarily in the future.

    If you were looking for ideas on improvement, the only thing I could see that could be 'better' is perhaps a label or two in the inspector that separates the "this" gameobject (in the clip) from the "that" gameobject.(allocated as the explicit target).

    2 questions:

    • As it stands now, I'm mildly confused as to what "FancyCubeBehavior" represents. Is that an EventHandler? What does "GoBig" come from in this case? Is it an animation, another timeline, a script, or what?
    • Also, what is the difference between the gameobject associated with the track vs. the gameobject associated with the "target" or whatever -- don't they both do the same thing essentially simply because you can only have one per track -- or am I missing something?
     
  14. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    27
    FancyCubeBehaviour is just a MonoBehaviour like any other, with some public methods on it (in this case, GoBig() and GoSmall()). The reflection bit looks for any MonoBehaviours on the associated objects, then exposes any public void methods without parameters. (currently no support for parameters in this first version)

    On the left of the track, you will see Cube1 is referenced there. That's the main output binding for the track. For example, when you have an audio track, there would be an audio source there, and the audio clips running along the track would be mixed through there. For the events system, we don't "mix" anything, so I just use that track binding as an alternative target for events, accessible per clip (orange stuff).

    Then, if you look at the clip inspector in the screenshot (the first clip on the track is selected), you will see there is a slot for dragging any GameObject there as well. In the example, Cube2 has been dragged there. So for each clip along the track, you can reference any other scene object as well, and it would usually not be the same one as the track binding on the left.

    So, ALL clips can fire events on the track binding (Cube1), and EACH clip can fire events on its own associated scene object as well, thus a total of 4 possible event handlers per clip.
     
    Last edited: Oct 25, 2017
  15. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    27
    Last edited: Nov 17, 2017
  16. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    327
    This is really great. Thanks man. :)

    Definitely a lot easier to understand now! -- There is only one thing not entirely clear interface-wise, but I think it may just be a matter of grouping -- would you mind adding something like this for each control group?

    https://docs.unity3d.com/ScriptReference/HeaderAttribute.html


    So, as I'm understanding it, this can fire either track events, clip events, or both simultaneously right?

    Can you pick just one or the other to ignore events for?

    Also, how difficult would it be to add arguments to these methods through the editor/inspector there?



    Just FYI -- your .unitypackage link is not working, though the demo one is.


    Thanks again for your hard work dude. This seems like it's exactly what many people here are looking for. Very usable, even as-is.
     
  17. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    27
    I will have a look, no problem.

    Correct - use track handlers and/or clip handlers within one clip, and optionally fire events at start of clip and/or end of clip. Any combination. Pretty flexible.

    I will play around with that instead of saying "simple" or "super impossible".
    I will refine things over the coming days as I'm experimenting with actually using it in our game
    It helps all the pain points to be identified.

    Fixed package link: http://farflunggames.com/download/Far-flungCreations_Timeline_Events_v0.1.zip

    No problem!
     
    luispedrofonseca likes this.
  18. Jokerminator

    Jokerminator

    Joined:
    Jun 30, 2006
    Posts:
    240
  19. shadow-river

    shadow-river

    Joined:
    May 29, 2013
    Posts:
    60
    Just wanted to share what I do to call events. I am using the text switcher from the Default Playables package, from there I have a Manager script on an empty game object which is set up to be pointed to all the functions I need called. the manager script points to the text object that is linked to all my text switcher tracks so that when a certain id string gets called through the switcher track my manager knows what function to fire. its very straight forward and awesome because I can have the text object on screen during testing so I can see what's firing and where problems lie.
     
  20. zibas

    zibas

    Joined:
    Sep 15, 2010
    Posts:
    23
    Clever! Worked great for me. Thanks.
     
  21. Daemonhahn

    Daemonhahn

    Joined:
    Oct 5, 2013
    Posts:
    272
    Great solution, thanks!
     
  22. wabugi

    wabugi

    Joined:
    Nov 4, 2014
    Posts:
    10
    @mgeorgedeveloper

    Awesome work! Your approach is more flexible than what I was working on. Would you mind if I use your event system im my project? Would really save me much headache :)
     
  23. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    27
    I don't mind at all, please go ahead. I dumped a package somewhere above. I still have to add parameter support to the event handlers, but at this moment the stuff I'm doing with this system thankfully works OK so far on event handlers requiring no parameters, so I've been holding off.
     
    wabugi likes this.
  24. wabugi

    wabugi

    Joined:
    Nov 4, 2014
    Posts:
    10
    Thank you! :)
     
  25. Kubic75

    Kubic75

    Joined:
    Jan 2, 2017
    Posts:
    53
    Just wanted to emphasize the need of triggering events from timeline.
    Hopefully a solution is in progress.
     
    Daemonhahn likes this.
  26. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    635
    mgeorgedeveloper likes this.
  27. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    327
    @mgeorgedeveloper -- I totally second that! -- Seems Timeline isn't going to have events in 2017.3 either is it?
     
    Last edited: Dec 6, 2017
    mgeorgedeveloper likes this.
  28. JacobSmaga

    JacobSmaga

    Joined:
    Aug 5, 2015
    Posts:
    207
    2018.1/2018.2, Early-mid 2018.
     
  29. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    1,317
    Unity please get some speed into your imemtentation of events!

    I had this working in production in games already 5 years ago with the help of aperure plugin, which is now depricated.

     
    awesomedata likes this.
  30. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    327
    To be totally honest -- that's quite irritating. Sure, it's coming, but why put Timeline out there as a "new feature" when it's clearly not finished? -- In the software-dev world, this style of implementation is usually called "experimental" -- or am I wrong for this label? -- After all, if Unity Team is nearly redoing the whole thing, then how can this be considered done?


    If that's legitimately their timeframe and they are *not* redoing most of it all over again, wth are they looking to accomplish in the meantime?? -- If this was an independent dev making an asset, that's one thing, but this is A HUGE CORPORATION, with lots of employees, but apparently not ever enough employees to manage all these important tiny-but-practical features -- only the next new "super cool new VR featurez!!" seem to matter these days. :/

    Granted, it's not like we can't wait patiently (and usually indefinitely too) until we're forced to just roll out our own solutions -- but why should we always have to supplement Unity's half-implemented features?


    Not everyone has a team of engineers working for them... but... wait. -- I guess Unity does.



    Sorry for being so pointed guys -- but this just seems like a trend that is never going to stop.
     
  31. extraneus

    extraneus

    Joined:
    Feb 28, 2013
    Posts:
    10
    Had to finally look into Timelines and could not believe that such an important feature is missing. At least we can implement our own playables. Thumbs up from that!

    There are some good and some not so good implementations suggested here. Being able to call custom functions from a timeline is one thing, but for me much of the power of events is based on publish-subscribe pattern, where the publisher (or in our case the timeline event) does not have to be aware of the subscribers. This is why I mostly use native C# events.

    In my opinion the simplest method is to use the OnBehaviourPlay and OnBehaviourPause callbacks to launch static C# events. To make static events any useful, we need to get the reference to the PlayableDirector, which is playing the timeline. The reference to it can be grasped in CreatePlayable method. It may also be handy to have a reference to an additional target object and to have some parameters.

    You can then listen to any timeline without having to setup references in the editor simply by registering to TimelineEvent.Playing and TimelineEvent.Paused events. The event has to be static, but we still need to know which timeline is sending the events. That's why we have the reference to the director, which is provided to the listeners as an argument. Via the director, we can also query it's state etc.

    Partial code:

    Code (CSharp):
    1. [Serializable]
    2. public class TimelineEventAsset : PlayableAsset, ITimelineClipAsset
    3. {
    4.     public bool launchEventsInEditorMode = true;
    5.     public ExposedReference<GameObject> optionalTarget;
    6.     public string optionalArgs = string.Empty;
    7.  
    8.     private TimelineEvent template = new TimelineEvent();
    9.  
    10.     public ClipCaps clipCaps
    11.     {
    12.         get { return ClipCaps.None; }
    13.     }
    14.  
    15.     public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    16.     {
    17.         var playable = ScriptPlayable<TimelineEvent>.Create(graph, template);
    18.         var instance = playable.GetBehaviour();
    19.         instance.launchEventsInEditorMode = launchEventsInEditorMode;
    20.         instance.director = owner.GetComponent<PlayableDirector>();
    21.         instance.optionalTarget = optionalTarget.Resolve(graph.GetResolver());
    22.         instance.optionalArgs = optionalArgs;
    23.         return playable;
    24.     }
    25. }
    26.  
    27. public class TimelineEvent : PlayableBehaviour
    28. {
    29.     public PlayableDirector director;
    30.     public GameObject optionalTarget;
    31.     public string optionalArgs = string.Empty;
    32.     public bool launchEventsInEditorMode;
    33.  
    34.     public static event EventHandler<TimelineEventArgs> Playing = (sender, args) => { };
    35.     public static event EventHandler<TimelineEventArgs> Paused = (sender, args) => { };
    36.  
    37.     public override void OnBehaviourPlay(Playable playable, FrameData info)
    38.     {
    39.         if (launchEventsInEditorMode || Application.isPlaying)
    40.         {
    41.             Playing(this, new TimelineEventArgs(director, info, optionalTarget, optionalArgs));
    42.         }
    43.     }
    44.  
    45.     public override void OnBehaviourPause(Playable playable, FrameData info)
    46.     {
    47.         if (launchEventsInEditorMode || Application.isPlaying)
    48.         {
    49.             Paused(this, new TimelineEventArgs(director, info, optionalTarget, optionalArgs));
    50.         }
    51.     }
     
  32. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    1,317
  33. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    273
    The way I've used events in my games is this code that I add to a gameobject.

    Code (csharp):
    1. public class TimelineEvent : MonoBehaviour {
    2.  
    3.    public bool FireEvent1;
    4.    public bool FireEvent2;
    5.  
    6.    void Start () {
    7.        if(FireEvent1) { Debug.Log("FireEvent1"); }
    8.        if(FireEvent2) { Debug.Log("FireEvent2"); }
    9.    }
    10.  
    11. }
    Then I drag this gameobject to the timeline to the place I want it as Activation Track. This way you need to add one gameobject per event for scene, but since in my game I only use timeline for cutscenes they don't usually have that many events that I need.
     
  34. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    1,317
    It would have been better to release with events, and later make a bug fix than to cut it.
    At least we could have worked in the mean time, now we just have to wait another 6 months.
     
    awesomedata likes this.