Sorry, I didn’t use the right terms in my previous post, my bad (I should have used the word delegate, not event). So, there will be a System.Action event in the PlayableDirector. You will be able to use the += and -= operators, but not the = operator, which is a good thing. We try to avoid creating new delegates in the scripting API, so this is why System.Action is used here.
Ohh. That makes much more sense now. I had a feeling something was off :p. That sounds great, thanks!
Hey all, just joining this thread and wanted to ask/confirm that if what is being discussed above would allow us to accomplish the use-cases mentioned in my original question here regarding skipping (and executing certain clips that had not yet played on skipping): Skipping Support
Thank you for any clarity on this!
Sorry to revive an old thread, but did a way to check the completion of a timeline iteration get added in 2017.3?
Are the timeline complete events on the way? I’m desparate for this…
If this feature is part of the timeline events:
[Timeline events?]( https://discussions.unity.com/t/668904 page-2#post-3354688)
The events on the playable director are available in 2018.1.
Having trouble atm because playableDirector.state always returns Paused even when playing, is this a bug?
I think i found a solution !
By time keeping the PlayableDirector.time if >0.
See if this works:
using UnityEngine;
using UnityEngine.Playables;
public class TimelineController : MonoBehaviour {
private double timeKeeper;
private PlayableDirector director;
public GameObject Intro, Level;
public bool ResetTimeline;
// Use this for initialization
void Start () {
director = GetComponent<PlayableDirector>();
director.Play();
}
// Update is called once per frame
void Update () {
if (director.state==PlayState.Paused && (timeKeeper+Time.deltaTime)>=director.duration)
{
//Transition animation play!!
Intro.SetActive(false);
Level.SetActive(true);
}
if (director.time>0)
{
timeKeeper = director.time;
}
if (ResetTimeline)
{
// Reset button
ResetTimeline = false;
// Resets level objects
Intro.SetActive(true);
Level.SetActive(false);
// Resets time keeping
timeKeeper = 0d;
// Resets director
director.Stop();
director.time = 0;
// Starts the timeline
Start();
}
}
}
Do you plan to have an OnComplete event ?
Thanks
No, but the stopped event will get called, unless it’s holding or looping.
Ok, so it means the stopped event can be used only for one of three wrap mode. Not really helpful and very disappointing choice regarding what has been imagined before : https://discussions.unity.com/t/676063/20
in hold mode, the stopped Event are not called. (latest unity Version). curriosly after i stop the Editor-Player.
The stopped event is not called in Hold/Loop because the timeline isn’t stopped, it’s still playing. The playable director stopped event refers to timeline being stopped and releasing it’s hold on any objects in the scene.
So, what is the best way to know when a timeline has reached the end of its longest layer (timeline not moving)? Checking the time and duration or activating a “messenger” object? I lost some hours trying to find out why the stopped event wasnt triggering, only to find out the reason. I think you should tell about this on the documentation.
Either way works. With 2019.1 you can add a signal at the end of the timeline to notify it has reached the end, even if it’s about to loop or hold.
It’s a good suggestion to add that to the documentation for the stopped event, we will look into doing that.
Thanks I ended up doing the event solution for now, but Ill suggest the team upgrading to 2019.1
I don’t recommend this because the playableDirector state returns Paused if the window loses focus (or if the editor is paused), which will make your game behave as if the timeline has ended when you click outside the window.
BTW @seant_unity can you confirm if this is intended behavior or a bug? I personally think it is a little weird (and dangerous) because normally we don’t expect that pausing the editor would affect the game state.
I would have to classify it as intended behaviour, although you are right, it is little weird. It returns pause because the time isn’t advancing. We really should have more states than Playing and Paused.
Ended uo here while using Unity 2020 and sad to see that yet again another feature that looks cool in unity is still only half supported.
An OnCOmplete event is really needed.