コード例 #1
0
        public static LevelEditor Create()
        {
            LevelEditor editor = (LevelEditor)GetWindow(typeof(LevelEditor));

            editor.titleContent = new GUIContent("Level");
            editor.CenterOnMainWindow();

            editor._lbdReader   = AssetDatabase.LoadAssetAtPath <LBDFastMeshSystem>("Assets/SDK/LBDFastMesh.asset");
            editor._levelLoader = AssetDatabase.LoadAssetAtPath <LevelLoaderSystem>("Assets/SDK/LevelLoader.asset");

            editor._entityTypes = getClasses(ENTITY_NAMESPACE);

            GameObject existingLevel = GameObject.Find("Level");

            if (existingLevel != null)
            {
                editor._levelObj = existingLevel;
            }

            editor.Show();
            return(editor);
        }
コード例 #2
0
        public void OnGUI()
        {
            EditorGUILayout.BeginHorizontal();
            _showEntireMenu = EditorGUILayout.Foldout(_showEntireMenu, "LSDR Dream Editor",
                                                      new GUIStyle("foldout")
            {
                fontStyle = FontStyle.Bold
            });
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Import", GUILayout.Width(100)))
            {
                importExistingDream();
            }
            if (GUILayout.Button("Export", GUILayout.Width(100)))
            {
                var path = EditorUtility.SaveFilePanel("Export dream", "", _dream.Name + ".json", "json");

                if (!string.IsNullOrEmpty(path))
                {
                    _serializer.Serialize(_dream, path);
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUI.indentLevel++;

            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
            if (_showEntireMenu)
            {
                EditorGUILayout.LabelField("Metadata", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;
                _dream.Name = EditorGUILayout.TextField(new GUIContent("Name", "The name of this dream"),
                                                        _dream.Name);
                _dream.Author = EditorGUILayout.TextField(new GUIContent("Author", "The author of this dream"),
                                                          _dream.Author);
                _dream.Type = (DreamType)EditorGUILayout.EnumPopup(
                    new GUIContent("Type", "The type of this dream, used to determine how to load the dream"),
                    _dream.Type);
                if (_dream.Type == DreamType.Legacy)
                {
                    _dream.LegacyTileMode = (LegacyTileMode)EditorGUILayout.EnumPopup(
                        new GUIContent("Tile mode", "The tiling mode of this dream"), _dream.LegacyTileMode);
                }

                if (_dream.LegacyTileMode == LegacyTileMode.Horizontal)
                {
                    _dream.TileWidth = EditorGUILayout.IntField(
                        new GUIContent("Tile width", "The width of the tile map"),
                        _dream.TileWidth);
                }

                EditorGUI.indentLevel--;
                EditorGUILayout.Separator();

                EditorGUILayout.LabelField("Graph", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;
                _dream.Upperness = EditorGUILayout.IntSlider(
                    new GUIContent("Upperness",
                                   "What effect this dream has on the 'upper' axis of the graph, when visited"), _dream.Upperness,
                    -9,
                    9);

                _dream.Dynamicness = EditorGUILayout.IntSlider(
                    new GUIContent("Dynamicness",
                                   "What effect this dream has on the 'dynamic' axis of the graph, when visited"),
                    _dream.Dynamicness,
                    -9,
                    9);
                EditorGUI.indentLevel--;
                EditorGUILayout.Separator();

                EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;

                _dream.Level = CommonGUI.BrowseFileField(new GUIContent("Level",
                                                                        "The path to the raw level file within the game's data to load for this dream."), _dream.Level,
                                                         "Choose a level file", new[] { "Torii map files", "tmap" });

                if (_dream.Type == DreamType.Legacy)
                {
                    _dream.LBDFolder = CommonGUI.BrowseFolderField(
                        new GUIContent("LBD folder", "The path to the LBD folder to load for this Dream."),
                        _dream.LBDFolder, "Choose an LBD folder.");
                }

                // only enable the button if the dream level has a value
                using (new EditorGUI.DisabledScope(string.IsNullOrWhiteSpace(_dream.Level)))
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Edit level", GUILayout.Width(200)))
                    {
                        var editor = LevelEditor.Create();
                        editor.EditLevel(_dream.Level);
                        if (_dream.Type == DreamType.Legacy)
                        {
                            editor.LoadLBD(_dream);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUI.indentLevel--;
                EditorGUILayout.Separator();

                EditorGUILayout.LabelField("Gameplay", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;
                _dream.GreyMan =
                    EditorGUILayout.Toggle(
                        new GUIContent("Grey man", "Whether or not this dream can spawn the grey man"),
                        _dream.GreyMan);
                EditorGUI.indentLevel--;
                EditorGUILayout.Separator();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Environment", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Add"))
                {
                    addNewDreamEnvironment();
                }

                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel++;
                for (int i = 0; i < _dream.Environments.Count; i++)
                {
                    drawDreamEnvironmentGUI(i);
                }

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndScrollView();

            EditorGUI.indentLevel--;
        }