private void OnTransitioned(SceneTransitionEventArgs e)
        {
            serializedSceneManager.SetActiveScene();

            e.DestinationScene = null;
            UpdateActiveTransition(e);
        }
Beispiel #2
0
 private void SceneManagerOnSceneTransitionStarted(Object sender, SceneTransitionEventArgs e)
 {
     if (this.hudScript != null)
     {
         this.hudScript.Close();
         this.hudScript = null;
         Game.Instance.SceneManager.SceneTransitionStarted -=
             SceneManagerOnSceneTransitionStarted;
     }
 }
Beispiel #3
0
 void consumeSceneTransitionEvent(object sender, SceneTransitionEventArgs transition)
 {
     print(transition.sceneTransitionMessage);
     StartCoroutine(LoadAsynchronously(nextSceneName));
 }
 private void UpdateActiveTransition(SceneTransitionEventArgs e)
 {
     NodeEditor.UpdateActiveTransition(e.InitialScene, e.DestinationScene);
     Repaint();
 }
 private void OnTransitionStarted(SceneTransitionEventArgs e)
 {
     UpdateActiveTransition(e);
 }
Beispiel #6
0
        private void SceneManagerOnSceneLoaded(object sender, SceneTransitionEventArgs e)
        {
            if (Game.InMenuScene)
            {
                // Run once
                Game.Instance.SceneManager.SceneTransitionCompleted -= SceneManagerOnSceneLoaded;

                if (!Screen.fullScreen)
                {
                    Debug.Log("Not in fullscreen mode.");
                    return;
                }

                var        oldResolution = Screen.currentResolution;
                Resolution?bestMatch     = null;
                foreach (var resolution in Screen.resolutions)
                {
                    if (!bestMatch.HasValue)
                    {
                        bestMatch = resolution;
                    }
                    else
                    {
                        var previousDelta = Math.Abs(oldResolution.width - bestMatch.Value.width);
                        if (Math.Abs(oldResolution.width - bestMatch.Value.width) <= previousDelta)
                        {
                            bestMatch = resolution;
                        }
                    }
                }

                if (bestMatch.HasValue &&
                    (oldResolution.width != bestMatch.Value.width || oldResolution.height != bestMatch.Value.height))
                {
                    var newResolution = bestMatch.Value;

                    Debug.Log($"Change Resolution: {Screen.currentResolution} --> {newResolution}");
                    Screen.SetResolution(newResolution.width, newResolution.height, Screen.fullScreen, newResolution.refreshRate);

                    var resolutionConfirmationDialog =
                        Game.Instance.UserInterface.CreateMessageDialog(
                            MessageDialogType.OkayCancel,
                            Game.Instance.UserInterface.Transform,
                            fadeIn: true
                            );

                    void resetResolution()
                    {
                        Debug.Log($"Reset Resolution: {Screen.currentResolution} --> {oldResolution}");
                        Screen.SetResolution(oldResolution.width, oldResolution.height, Screen.fullScreen, oldResolution.refreshRate);
                    }

                    var baseText =
                        $"Changed resolution to {newResolution.width} x {newResolution.height}\n How does this look?\n" +
                        $"Reverting resolution change in [t] seconds, just in case something went wrong.";
                    var endTime = Time.time + 10f;

                    resolutionConfirmationDialog.MessageText    = baseText.Replace("[t]", (endTime - Time.time).ToString("0"));
                    resolutionConfirmationDialog.CancelClicked += dialog => {
                        resetResolution();
                        dialog.Close();
                    };
                    resolutionConfirmationDialog.OkayClicked += dialog => {
                        var resolutionSetting = Game.Instance.Settings.Quality.Display.Resolution;
                        resolutionSetting.Value = newResolution;
                        resolutionSetting.CommitChanges();
                        Game.Instance.Settings.Save();

                        dialog.Close();
                    };

                    UnityEventDispatcher.Instance.ExecuteCustomYield(
                        () => {
                        if (resolutionConfirmationDialog == null)
                        {
                            return(false);
                        }

                        resolutionConfirmationDialog.MessageText = baseText.Replace("[t]", (endTime - Time.time).ToString("0"));
                        return(Time.time < endTime);
                    },
                        () => {
                        if (!(resolutionConfirmationDialog != null))
                        {
                            return;
                        }

                        // Timeout
                        resetResolution();
                        resolutionConfirmationDialog.Close();
                    }
                        );
                }
            }
        }