private IEnumerator DelayedActiveSceneChanged(Scene from, Scene to) { initialized = true; bool isRestart = isRestartingSong; isRestartingSong = false; yield return(waitMainCamera()); if (!isRestart) { CameraUtilities.ReloadCameras(); } IEnumerator waitForcam() { yield return(new WaitForSeconds(0.1f)); while (Camera.main == null) { yield return(new WaitForSeconds(0.05f)); } } if (PluginConfig.Instance.ProfileSceneChange && !isRestart) { if (!MultiplayerSession.ConnectedMultiplay || PluginConfig.Instance.MultiplayerProfile == "") { if (to.name == "GameCore" && PluginConfig.Instance.RotateProfile != "" && LevelDataPatch.is360Level) { CameraUtilities.ProfileChange(PluginConfig.Instance.RotateProfile); } else if (to.name == "GameCore" && PluginConfig.Instance.GameProfile != "") { CameraUtilities.ProfileChange(PluginConfig.Instance.GameProfile); } else if ((to.name == "MainMenu" || to.name == "MenuCore" || to.name == "HealthWarning") && PluginConfig.Instance.MenuProfile != "") { CameraUtilities.ProfileChange(PluginConfig.Instance.MenuProfile); } } } if (ActiveSceneChanged != null) { yield return(waitForcam()); // Invoke each activeSceneChanged event foreach (var func in ActiveSceneChanged?.GetInvocationList()) { try { func?.DynamicInvoke(from, to); } catch (Exception ex) { Logger.log.Error($"Exception while invoking ActiveSceneChanged:" + $" {ex.Message}\n{ex.StackTrace}"); } } } else if (PluginConfig.Instance.ProfileSceneChange && to.name == "HealthWarning" && PluginConfig.Instance.MenuProfile != "") { CameraUtilities.ProfileChange(PluginConfig.Instance.MenuProfile); } yield return(waitForcam()); if (to.name == "GameCore") { origin = GameObject.Find("LocalPlayerGameCore/Origin")?.transform; } if (to.name == "MainMenu") { var chat = GameObject.Find("ChatDisplay"); if (chat) { chat.layer = Layer.UI; } } }