void Update()
    {
        if (Input.GetKeyDown(KeyCode.F8) && Input.GetKey(KeyCode.LeftControl))
        {
            PerfBenchmark.CommandBenchmark(null);
        }

#if UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.F9) && Input.GetKey(KeyCode.LeftControl))
        {
            var gameOpts = new GameBuilderApplication.GameOptions
            {
                playOptions = new GameBuilderApplication.PlayOptions
                {
                    isMultiplayer    = true,
                    startAsPublic    = false,
                    startInBuildMode = true
                }
            };
            string path = System.IO.Path.Combine(Application.streamingAssetsPath, "ExampleGames", "Internal", "template-small.voos");
            loadingScreen.ShowAndDo(() => sceneController.RestartAndLoad(path, gameOpts));
        }
#endif

#if UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.F10) && Input.GetKey(KeyCode.LeftControl))
        {
            sceneController.JoinMultiplayerGameByCode($"1-dev-{System.Net.Dns.GetHostName().ToLowerInvariant()}");
        }
#endif

        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.N))
        {
            sceneController.RestartAndLoadMinimalScene(new GameBuilderApplication.GameOptions());
        }

        if (Input.GetButtonDown("Cancel"))
        {
            if (creditsObject.activeSelf)
            {
                creditsObject.SetActive(false);
            }
            else if (templateSelectorMenu.IsOpen())
            {
                templateSelectorMenu.Close();
            }
            else
            {
                menuPanelManager.Back();
            }
        }

        AudioListener.volume = Application.isFocused ? 1 : 0;
    }
Пример #2
0
    public override void OnConnectionFail(DisconnectCause cause)
    {
        if (cause == DisconnectCause.InvalidRegion)
        {
            OnInvalidJoinCodeRegion();
        }
        else
        {
            voosEngine.HackyForceSetIsRunning(false);

            if (Time.unscaledTime > 10f)
            {
                autosaves.SetPaused(true);
                autosaves.TriggerAutosave(autosaveBundleId =>
                {
                    if (numOthersWhenConnected == 0)
                    {
                        string userMessage = $"Woops! You were disconnected. Reason:\n{cause.ToString()}\nWe've auto-saved the project, so you can recover it and restart the multiplayer session.";
                        Util.LogError(userMessage);
                        popups.ShowTwoButtons(userMessage,
                                              "Recover Autosave",
                                              () =>
                        {
                            scenes.RestartAndLoadLibraryBundle(gameBundleLibrary.GetBundleEntry(autosaveBundleId), new GameBuilderApplication.PlayOptions());
                        },
                                              "Go to Main Menu",
                                              () => scenes.LoadSplashScreen(),
                                              800f
                                              );
                    }
                    else
                    {
                        string userMessage = $"Woops! You were disconnected. Reason:\n{cause.ToString()}. Please reconnect.\n<size=80%><color=#888888>NOTE: If the multiplayer game is gone, you can recover the autosave in your Game Library.</color></size>";
                        Util.LogError(userMessage);
                        popups.ShowTwoButtons(
                            userMessage,
                            $"Reconnect to {roomNameWhenConnected}",
                            () => scenes.JoinMultiplayerGameByCode(roomNameWhenConnected),
                            "Go to Main Menu",
                            () => scenes.LoadSplashScreen(),
                            800f);
                    }
                });
            }
            else
            {
                string userMessage = $"Woops! You were disconnected. Reason:\n{cause.ToString()}.";
                Util.LogError(userMessage);
                popups.Show(userMessage, "Back to Main Menu", () =>
                {
                    scenes.LoadSplashScreen();
                });
            }
        }
    }