Exemplo n.º 1
0
    public PWMainPresetScreen(PWMainGraph mainGraph)
    {
        this.mainGraph = mainGraph;

        //loading preset panel images
        preset2DSideViewTexture     = Resources.Load <Texture2D>("preview2DSideView");
        preset2DTopDownViewTexture  = Resources.Load <Texture2D>("preview2DTopDownView");
        preset3DPlaneTexture        = Resources.Load <Texture2D>("preview3DPlane");
        preset3DSphericalTexture    = Resources.Load <Texture2D>("preview3DSpherical");
        preset3DCubicTexture        = Resources.Load <Texture2D>("preview3DCubic");
        preset1DDensityFieldTexture = Resources.Load <Texture2D>("preview1DDensityField");
        preset2DDensityFieldTexture = Resources.Load <Texture2D>("preview2DDensityField");
        preset3DDensityFieldTexture = Resources.Load <Texture2D>("preview3DDensityField");
        // presetMeshTetxure = Resources.Load< Texture2D >("previewMesh");

        PresetCellList presets = new PresetCellList()
        {
            { "2D Terrains", preset2DSideViewTexture, "2D sideview procedural terrain", Build2DSideView, false },
            { "2D Terrains", preset2DTopDownViewTexture, "2D top down procedural terrain", Build2DTopDown, true },
            { "3D Terrains", preset3DPlaneTexture, "3D plane procedural terrain", Build3DPlanar, false },
            { "3D Terrains", preset3DSphericalTexture, "3D spherical procedural terrain", Build3DSpherical, false },
            { "3D Terrains", preset3DCubicTexture, "3D cubic procedural terrain", Build3DCubic, false },
            { "Density Fields", preset1DDensityFieldTexture, "1D float density field", Build1DDensity, false },
            { "Density Fields", preset2DDensityFieldTexture, "2D float density field", Build2DDensity, false },
            { "Density Fields", preset3DDensityFieldTexture, "3D float density field", Build3DDensity, false },
        };

        LoadPresetList(presets);
    }
Exemplo n.º 2
0
        int DrawColumn(PresetCellList presetList, int columnIndex)
        {
            int newSelectedIndex = selectedIndices[columnIndex];

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
            scrollBars[columnIndex] = EditorGUILayout.BeginScrollView(scrollBars[columnIndex], GUILayout.ExpandWidth(true));
            {
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.LabelField(presetList.header, EditorStyles.whiteBoldLabel);
                    GUILayout.FlexibleSpace();
                }
                EditorGUILayout.EndHorizontal();

                int i = 0;
                foreach (var preset in presetList)
                {
                    if (DefaultDrawCell(preset, i == newSelectedIndex, columnIndex))
                    {
                        newSelectedIndex = i;
                    }
                    i++;
                }
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            return(newSelectedIndex);
        }
        public BiomePresetScreen(BiomeGraphEditor biomeGraphEditor, bool loadStyle = true)
        {
            this.biomeGraphEditor = biomeGraphEditor;

            Texture2D plainTexture     = Resources.Load <Texture2D>("");
            Texture2D mountainTexture  = Resources.Load <Texture2D>("");
            Texture2D mesaTexture      = Resources.Load <Texture2D>("");
            Texture2D swamplandTexture = Resources.Load <Texture2D>("");

            PresetCellList earthLikePresets = new PresetCellList()
            {
                { "Biome preset" },
                { "Plains / Prairies", plainTexture, "Earth/Plain" },
                { "Mountains", mountainTexture, "Earth/Mountain", false },
                { "Mesas", mesaTexture, "Earth/Mesa", false },
                { "Swamplands", swamplandTexture, "Earth/Swampland", false },
            };

            PresetCellList presets = new PresetCellList
            {
                { "Biome category" },
                { "Earth like biomes", null, (string)null, true, earthLikePresets }
            };

            LoadPresetList(presets);

            if (loadStyle)
            {
                LoadStyle();
            }
        }
Exemplo n.º 4
0
        protected void LoadPresetList(PresetCellList presets)
        {
            presetList = presets;

            UpdateColumnCount();
            UpdateSelectedList();
            UpdateGraphPartFiles();
        }
Exemplo n.º 5
0
    protected void LoadPresetList(PresetCellList presets)
    {
        presetCellList = presets;

        buttonStyle = new GUIStyle("button");
        buttonStyle.imagePosition = ImagePosition.ImageAbove;
        buttonStyle.alignment     = TextAnchor.MiddleCenter;
        buttonStyle.fontSize      = 12;
    }
Exemplo n.º 6
0
    public PWBiomePresetScreen(PWBiomeGraph biomeGraph)
    {
        this.biomeGraph = biomeGraph;

        plainTexture     = Resources.Load <Texture2D>("");
        mountainTexture  = Resources.Load <Texture2D>("");
        mesaTexture      = Resources.Load <Texture2D>("");
        swamplandTexture = Resources.Load <Texture2D>("");

        PresetCellList presets = new PresetCellList()
        {
            { "Earth-like", plainTexture, "Plains / Prairies", BuildPlain },
            { "Earth-like", mountainTexture, "Mountains", BuildMountains },
            { "Earth-like", mesaTexture, "Mesas", BuildMesa },
            { "Earth-like", swamplandTexture, "Swamplands", BuildSwampland },
        };

        LoadPresetList(presets);
    }
Exemplo n.º 7
0
        void UpdateSelectedList()
        {
            int i = 0;

            selectedIndices.Clear();
            PresetCellList currentList = presetList;

            while (currentList != null)
            {
                int index = currentList.FindIndex(l => l.enabled);

                if (index == -1)
                {
                    return;
                }

                currentList = currentList[index].childs;

                selectedIndices.Add(index);
                i++;
            }
        }
Exemplo n.º 8
0
        void UpdateGraphPartFiles()
        {
            int i = 0;

            PresetCellList currentList = presetList;

            graphPartFiles.Clear();
            while (currentList != null)
            {
                int index = selectedIndices[i];
                var cell  = currentList[index];

                if (!String.IsNullOrEmpty(cell.graphPartFile))
                {
                    graphPartFiles.Add(cell.graphPartFile);
                }

                currentList = cell.childs;

                selectedIndices.Add(index);
                i++;
            }
        }
Exemplo n.º 9
0
        public PresetCellList LoadPresetBoard()
        {
            //loading preset panel images
            Texture2D preset2DSideViewTexture  = Resources.Load <Texture2D>("PresetImages/preview2DSideView");
            Texture2D preset2DPlanarTexture    = Resources.Load <Texture2D>("PresetImages/preview2DTopDownView");
            Texture2D preset3DPlanarTexture    = Resources.Load <Texture2D>("PresetImages/preview3DPlane");
            Texture2D preset3DSphericalTexture = Resources.Load <Texture2D>("PresetImages/preview3DSpherical");
            Texture2D preset3DCubicTexture     = Resources.Load <Texture2D>("PresetImages/preview3DCubic");

            //Biomes
            PresetCellList biomePresets = new PresetCellList
            {
                { "Biome presets" },
                { "Earth like", null, "Biomes/Earth", true }
            };

            //ISO surfaces
            PresetCellList terrain2DIsoSurfaces = new PresetCellList
            {
                { "2D Isosurfaces" },
                { "Square", null, "IsoSurfaces/Square", true, biomePresets },
                { "Hexagon", null, "IsoSurfaces/Hexagon", false, biomePresets },
                { "Marching cubes 2D", null, "IsoSurfaces/MarchingCubes2D", false, biomePresets },
                { "Fake voxels", null, "IsoSurfaces/FakeVolxel", false, biomePresets },
            };

            PresetCellList terrain3DIsoSurfaces = new PresetCellList
            {
                { "3D Isosurfaces" },
                { "Marching cubes 3D", null, "IsuSurfaces/MarchingCubes3D", false, biomePresets },
                { "Dual countering 3D", null, "IsoSurfaces/DualCountering", false, biomePresets },
                { "Greedy voxels", null, "IsoSurfaces/GreedyVoxel", false, biomePresets }
            };

            //Output type
            PresetCellList terrain3DPresets = new PresetCellList
            {
                { "3D Terrain type" },
                { "3D planar", preset3DPlanarTexture, "TerrainType/Planar3D", false, terrain3DIsoSurfaces },
                { "3D spherical", preset3DSphericalTexture, "TerrainType/Spherical3D", false, terrain3DIsoSurfaces },
                { "3D cubic", preset3DCubicTexture, "TerrainType/Cubic3D", false, terrain3DIsoSurfaces },
            };

            PresetCellList terrain2DPresets = new PresetCellList
            {
                { "2D Terrain type" },
                { "2D flat", preset2DPlanarTexture, "TerrainType/Planar2D", true, terrain2DIsoSurfaces },
                { "2D spherical", null, "TerrainType/Spherical2D", false, terrain2DIsoSurfaces },
                { "2D cubic", preset2DPlanarTexture, "TerrainType/Cubic2D", false, terrain2DIsoSurfaces },
                { "Side view like terraria", preset2DSideViewTexture, "Base/SideView", false },
            };

            PresetCellList outputTypePresets = new PresetCellList
            {
                { "Terrain type" },
                { "2D Terrain like civilization", preset2DPlanarTexture, "Base/2D", true, terrain2DPresets },
                { "3D Terrain like minecraft", preset3DPlanarTexture, "Base/3D", false, terrain3DPresets },
            };

            return(outputTypePresets);
        }
Exemplo n.º 10
0
            public void Add(string name, Texture2D texture, string graphPartFile, bool enabled = true, PresetCellList childList = null)
            {
                PresetCell pc = new PresetCell
                {
                    texture       = texture,
                    name          = name,
                    graphPartFile = graphPartFile,
                    enabled       = enabled,
                    childs        = childList
                };

                this.Add(pc);
            }