Description
Summary
LoadingBehaviour can have a delayed end, but there is no way to know when the delay actually ended
Problem or Use Case
If you want to animate the newly open scene and you do it on Start
you will start animating while a transition is still on screen.
Having a way to check with the manager if the transition scene is completely gone is nice.
I usually call this method a "DelayedStart"
Proposed Solution
We have the timing here:
The idea would be a TransitionSceneEnded
that if no transition (empty, without delayed start Behaviour or without behaviour) triggers right after ActiveSceneChanged
but if a Delayed End TransitionBehaviour is used then the call happens after await progress.TransitionOutTask.Task;
I am not sure if a TransitionSceneStarted
for delayed Starts would be useful, but could be added for symmetry 🤷♀
Workarround:
public class DelayedStartBehaviourMB : MonoBehaviour
{
private void Start()
{
LoadingBehavior loadingBehavior = UnityEngine.Object.FindObjectsByType<LoadingBehavior>(FindObjectsSortMode.None)
.FirstOrDefault(l => l.gameObject.scene != this.gameObject.scene); //If the scene is not my scene, it must be a loading scene
if (loadingBehavior == null || !loadingBehavior.waitForScriptedEnd)
{
// Immediate start
this.DelayedStart();
}
else
{
// Wait for the Progress Transition Out Task start
loadingBehavior.Progress.TransitionOutTask.Task.ContinueWith((_) => this.DelayedStart());
}
}
private void DelayedStart()
{
// Do fancy animations here. We are cool.
}
}
Acknowledgement
- I have searched the existing issues to ensure this feature hasn't been requested already