示例#1
0
    IEnumerator SavingCoroutine()
    {
        while (true)
        {
            yield return(new WaitForSecondsRealtime(periodSeconds));

            // Don't autosave during recovery mode. You might be overwriting an
            // autosave that the user wants to recover!
            if (this.isActiveAndEnabled && !GameBuilderApplication.IsRecoveryMode && !paused)
            {
                try
                {
                    DoAutosave(bundleId =>
                    {
                        // HACK HACK. Only because CMS is tied to player panels, when it really should be global.
                        if (notes == null)
                        {
                            notes = FindObjectOfType <HudNotifications>();
                        }

                        if (notes != null)
                        {
                            notes.AddMessage($"Auto-saved!");
                        }
                    });
                }
                catch (System.Exception e)
                {
                    popups.ShowTwoButtons(
                        $"Woops! Failed to autosave due to error:\n{e.Message}\nWe will disable autosaves until you restart Game Builder. Apologies for the error!",
                        "OK", () => { },
                        "Copy error details", () => { Util.CopyToUserClipboard(e.ToString()); },
                        800f);
                    SetPaused(true);
                }
            }
        }
    }