loadsceneasync causes a hiccup, this hiccup throws the timeline out of sync with audio, the timeline is set to DSP clock, what’s the solution?
Please file a bug with your use case.
I’ve got a potential fix for that, but I’ve been looking for a repro to test against
1 Like
alright I filled that bug
here is the repro data in picture
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.SceneManagement;
public class TimelineSceneLoadAsync : PlayableAsset
{
#if UNITY_EDITOR
[Multiline] public string comment;
#endif
public SceneReference sceneName;
public AsyncDataPipe_SO asyncDataPipeSo;
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
var playable = ScriptPlayable<TimelineSceneLoadAsyncBehaviour>.Create(graph);
var sceneLoadBehaviour = playable.GetBehaviour();
sceneLoadBehaviour.sceneName = sceneName;
sceneLoadBehaviour.asyncDataPipeSo = asyncDataPipeSo;
return playable;
}
}
public class TimelineSceneLoadAsyncBehaviour : PlayableBehaviour
{
public string sceneName = "";
public AsyncDataPipe_SO asyncDataPipeSo;
public override void OnBehaviourPlay(Playable playable, FrameData info)
{
asyncDataPipeSo.async = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
asyncDataPipeSo.extraData = sceneName;
asyncDataPipeSo.async.allowSceneActivation = false;
}
}
also of note: activating hiccups a lot more than normal
activation script
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.SceneManagement;
public class TimelineSceneActivate : PlayableAsset
{
#if UNITY_EDITOR
[Multiline] public string comment;
#endif
public AsyncDataPipe_SO asyncDataPipeSo;
public bool setSceneActive;
public SceneReference sceneToUnload;
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
var playable = ScriptPlayable<TimelineSceneActivateBehaviour>.Create(graph);
var sceneActivateBehaviour = playable.GetBehaviour();
sceneActivateBehaviour.asyncDataPipeSo = asyncDataPipeSo;
sceneActivateBehaviour.setSceneActive = setSceneActive;
sceneActivateBehaviour.sceneToUnload = sceneToUnload;
return playable;
}
}
public class TimelineSceneActivateBehaviour : PlayableBehaviour
{
public AsyncDataPipe_SO asyncDataPipeSo;
public bool setSceneActive;
public SceneReference sceneToUnload;
public override void OnBehaviourPlay(Playable playable, FrameData info)
{
if (asyncDataPipeSo.async != null)
asyncDataPipeSo.async.allowSceneActivation = true;
asyncDataPipeSo.async = null;
if (setSceneActive)
SceneManager.SetActiveScene(SceneManager.GetSceneByPath(asyncDataPipeSo.extraData));
//unloading
if (!string.IsNullOrEmpty(sceneToUnload.ScenePath))
SceneManager.UnloadSceneAsync(sceneToUnload);
}
}
async datapipe:
using UnityEngine;
[CreateAssetMenu(menuName = "SO/Async (data pipe)")]
public class AsyncDataPipe_SO : ScriptableObject
{
public AsyncOperation async;
public string extraData;
}
bug # 1322234