コード例 #1
0
    private IEnumerator LoadCoroutine()
    {
        yield return(null);

        try
        {
            ReadWorldFile.Read(SelectedWorld.GetLoadStream(),
                               null, GetComponent <VoxelArray>(), false);
        }
        catch (MapReadException e)
        {
            var dialog = loadingGUI.gameObject.AddComponent <DialogGUI>();
            dialog.message          = e.FullMessage;
            dialog.yesButtonText    = "Close";
            dialog.yesButtonHandler = () =>
            {
                Close(Scenes.MENU);
            };
            Debug.LogError(e.InnerException);
            yield break;
        }
        finally
        {
            Destroy(loadingGUI);
        }
    }
コード例 #2
0
ファイル: EditorFile.cs プロジェクト: bmjoy/voxel-editor
 public void Save()
 {
     if (!voxelArray.unsavedChanges)
     {
         Debug.unityLogger.Log("EditorFile", "No unsaved changes");
         return;
     }
     MessagePackWorldWriter.Write(SelectedWorld.GetSavePath(),
                                  cameraPivot, voxelArray);
     voxelArray.unsavedChanges = false;
 }
コード例 #3
0
 public void LoadLobby()
 {
     GameplayManager.Instance.SaveSesion();
     SelectedWorld.Save();
     SelectedWorld = null;
     SceneManager.LoadScene(0);
     guiCamera.gameObject.SetActive(false);
     guiCamera.gameObject.SetActive(true);
     MenuManager.Instance.OpenMenu("Main_Menu");
     MenuManager.Instance.OpenMenu("Lobby_Menu");
 }
コード例 #4
0
        private void LoadExistingSettings()
        {
            var xmlDoc = LoadPrefsFile();
            var root   = xmlDoc.Descendants().First();

            if (root.Descendants("WORLD").Any())
            {
                var  selectedVal = root.Descendants("WORLD").Single().Value;
                nint valAsInt;
                if (nint.TryParse(selectedVal, out valAsInt))
                {
                    var listItem = SelectedWorld.Items().SingleOrDefault(i => i.Tag == valAsInt);
                    SelectedWorld.SelectItem(listItem);
                }
            }
        }
コード例 #5
0
    public static void OpenDemoWorld(string name, string templateName)
    {
        if (EditorFile.instance != null)
        {
            EditorFile.instance.Save();
        }

        TextAsset worldAsset = Resources.Load <TextAsset>(templateName);
        string    path       = WorldFiles.GetNewWorldPath(name);

        for (int i = 2; File.Exists(path); i++) // autonumber
        {
            path = WorldFiles.GetNewWorldPath(name + " " + i);
        }
        SelectedWorld.SelectDemoWorld(worldAsset, path);
        SceneManager.LoadScene(Scenes.EDITOR);
    }
コード例 #6
0
ファイル: EditorFile.cs プロジェクト: bmjoy/voxel-editor
    private IEnumerator LoadCoroutine()
    {
        yield return(null);

        var guiGameObject = loadingGUI.gameObject;

        List <string> warnings;

        try
        {
            warnings = ReadWorldFile.Read(SelectedWorld.GetLoadStream(),
                                          cameraPivot, voxelArray, true);
        }
        catch (MapReadException e)
        {
            var dialog = guiGameObject.AddComponent <DialogGUI>();
            dialog.message          = e.Message;
            dialog.yesButtonText    = "Close";
            dialog.yesButtonHandler = () =>
            {
                voxelArray.unsavedChanges = false;
                Close();
            };
            Destroy(loadingGUI);
            Debug.LogError(e);
            yield break;
        }
        // reading the file creates new voxels which sets the unsavedChanges flag
        // and clears existing voxels which sets the selectionChanged flag
        voxelArray.unsavedChanges   = false;
        voxelArray.selectionChanged = false;

        Destroy(loadingGUI);
        foreach (MonoBehaviour b in enableOnLoad)
        {
            b.enabled = true;
        }

        if (PlayerPrefs.HasKey("last_editScene_version"))
        {
            string lastVersion = PlayerPrefs.GetString("last_editScene_version");
            if (CompareVersions(lastVersion, "1.2.0") == -1)
            {
                var dialog = guiGameObject.AddComponent <DialogGUI>();
                dialog.message          = "N-Space has been updated with the ability to bevel edges! Would you like a tutorial?";
                dialog.yesButtonText    = "Yes";
                dialog.noButtonText     = "No";
                dialog.yesButtonHandler = () =>
                {
                    TutorialGUI.StartTutorial(Tutorials.BEVEL_TUTORIAL, guiGameObject, voxelArray, touchListener);
                };
            }
            else if (CompareVersions(lastVersion, "1.3.0") == -1)
            {
                LargeMessageGUI.ShowLargeMessageDialog(guiGameObject, "<b>Version 1.3.0 update</b>\n\n"
                                                       + "N-Space has been updated with a new behavior for sound effects and music. Try it out!\n\n"
                                                       + "Also, check the main menu for links to video tutorials and a subreddit.");
            }
        }
        PlayerPrefs.SetString("last_editScene_version", Application.version);

        if (warnings.Count > 0)
        {
            // avoids a bug where two dialogs created on the same frame will put the unfocused one on top
            // for some reason it's necessary to wait two frames
            yield return(null);

            yield return(null);

            string message = "There were some issues with reading the world:\n\n  •  " +
                             string.Join("\n  •  ", warnings.ToArray());
            LargeMessageGUI.ShowLargeMessageDialog(guiGameObject, message);
        }
    }
コード例 #7
0
ファイル: MenuGUI.cs プロジェクト: bmjoy/voxel-editor
 public static void OpenWorld(string path, string scene)
 {
     SelectedWorld.SelectSavedWorld(path);
     SceneManager.LoadScene(scene);
 }