only wait a frame in QSBWorldSync

This commit is contained in:
JohnCorby 2022-05-03 22:55:09 -07:00
parent cdb42e6726
commit cdd87e9a39
2 changed files with 11 additions and 10 deletions

View File

@ -18,13 +18,13 @@ public static class QSBSceneManager
public static event Action<OWScene, OWScene> OnUniverseSceneLoaded;
/// <summary>
/// runs before the scene is changed
/// and objects are destroyed
/// runs before the scene is changed.
/// happens before OnDestroy.
/// </summary>
public static event LoadManager.SceneLoadEvent OnPreSceneLoad;
/// <summary>
/// runs after the scene has changewd
/// and objects are awakened and started
/// runs after the scene is changed.
/// happens after Awake, but before Start.
/// </summary>
public static event LoadManager.SceneLoadEvent OnPostSceneLoad;
@ -38,11 +38,10 @@ public static class QSBSceneManager
OnPreSceneLoad?.SafeInvoke(originalScene, loadScene);
};
LoadManager.OnCompleteSceneLoad += (originalScene, loadScene) =>
Delay.RunNextFrame(() =>
{
DebugLog.DebugWrite($"POST SCENE LOAD ({originalScene} -> {loadScene})", MessageType.Info);
OnPostSceneLoad?.SafeInvoke(originalScene, loadScene);
});
{
DebugLog.DebugWrite($"POST SCENE LOAD ({originalScene} -> {loadScene})", MessageType.Info);
OnPostSceneLoad?.SafeInvoke(originalScene, loadScene);
};
DebugLog.DebugWrite("Scene Manager ready.", MessageType.Success);
}

View File

@ -187,7 +187,9 @@ public static class QSBWorldSync
{
if (QSBCore.IsInMultiplayer && loadScene.IsUniverseScene())
{
BuildWorldObjects(loadScene).Forget();
// So objects have time to be deleted, made, whatever
// I.E. wait until Start has been called
Delay.RunNextFrame(() => BuildWorldObjects(loadScene).Forget());
}
};