Example #1
0
    void DrawObjectsTable()
    {
        List <TableColumn> columns = new List <TableColumn>()
        {
            new TableColumn("String", TableColumn.Width(60f)),
            new TableColumn("Float", TableColumn.Width(50f)),
            new TableColumn("Object", TableColumn.Width(110f)),
            new TableColumn("", TableColumn.Width(50f), TableColumn.EnabledTitle(false))
        };

        List <List <TableCell> > rows = new List <List <TableCell> >();

        ActionExample targetObject = (ActionExample)target;

        for (int i = 0; i < targetObject.simpleObjects.Count; i++)
        {
            ActionExample.SimpleObject entry = targetObject.simpleObjects[i];
            rows.Add(new List <TableCell>()
            {
                new LabelCell(entry.stringProperty),
                new PropertyCell(serializedObject, string.Format("simpleObjects.Array.data[{0}].floatProperty", i)),
                new PropertyCell(serializedObject, string.Format("simpleObjects.Array.data[{0}].objectProperty", i)),
                new ActionCell("Reset", () => entry.Reset()),
            });
        }

        tableState = GUITableLayout.DrawTable(tableState, columns, rows);
    }
Example #2
0
	public override void OnInspectorGUI ()
	{
		base.OnInspectorGUI();
		SerializedObject serializedObject = new SerializedObject(LogoTable.Instance);

		List<TableColumn> columns = new List<TableColumn>()
		{
			new TableColumn("G", 28f),
			new TableColumn("U", 22f),
			new TableColumn("I     ", 35f),
		};

		List<List<TableCell>> rows = new List<List<TableCell>>();

		LogoTable targetObject = LogoTable.Instance;

		for (int i = 0 ; i < targetObject.logoLines.Count ; i++)
		{
			rows.Add (new List<TableCell>()
			{
				new PropertyCell (serializedObject, string.Format("logoLines.Array.data[{0}].letter1", i)),
				new PropertyCell (serializedObject, string.Format("logoLines.Array.data[{0}].letter2", i)),
				new PropertyCell (serializedObject, string.Format("logoLines.Array.data[{0}].color", i)),
			});
		}

		tableState = GUITableLayout.DrawTable (tableState, columns, rows);
	}
    void MultiplePerlin()
    {
        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perlin");

        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Multiple Perlin Noise", EditorStyles.boldLabel);

            perlinParametersTable = GUITableLayout.DrawTable(
                perlinParametersTable, perlinParameters, GUITableOption.Reorderable(true));

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }

            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }

            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply Multiple Perlin"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }
    }
Example #4
0
    private void DrawCustomCells()
    {
        var serializedObject = new SerializedObject(SimpleExample.Instance);

        var columns = new List <TableColumn>
        {
            new TableColumn("String", 60f),
            new TableColumn("Float", 50f),
            new TableColumn("Object", 110f),
            new TableColumn("", TableColumn.Width(100f), TableColumn.EnabledTitle(false))
        };

        var rows = new List <List <TableCell> >();

        var targetObject = (SimpleExample)serializedObject.targetObject;

        for (var i = 0; i < targetObject.simpleObjects.Count; i++)
        {
            var entry = targetObject.simpleObjects[i];
            rows.Add(new List <TableCell>
            {
                new LabelCell(entry.stringProperty),
                new PropertyCell(serializedObject, string.Format("simpleObjects.Array.data[{0}].floatProperty", i)),
                new PropertyCell(serializedObject, string.Format("simpleObjects.Array.data[{0}].objectProperty", i)),
                new ActionCell("Reset", () => entry.Reset())
            });
        }

        tableState = GUITableLayout.DrawTable(tableState, columns, rows);
    }
Example #5
0
    private void SplatMapsGUI(CustomTerrain terrain)
    {
        showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps");
        if (showSplatMaps)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Splat Maps", EditorStyles.boldLabel);

            EditorGUILayout.Slider(blendingNoiseMultiplier, 0.1f, 1f, new GUIContent("Noise Multiplier"));
            EditorGUILayout.Slider(blendingNoiseParams, 0.001f, 0.1f, new GUIContent("Noise Parameters"));
            EditorGUILayout.Slider(blendingOffset, 0.001f, 0.1f, new GUIContent("Noise Offset"));

            splatMapTable = GUITableLayout.DrawTable(splatMapTable,
                                                     serializedObject.FindProperty(nameof(terrain.splatHeights)));
            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewSplatHeight();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply"))
            {
                terrain.SplatMaps();
            }
        }
    }
Example #6
0
    private void MultiplePerlinGUI(CustomTerrain terrain)
    {
        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perline Noises");
        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Multiple Perline Noises", EditorStyles.boldLabel);
            perlinParametrsTable = GUITableLayout.DrawTable(perlinParametrsTable,
                                                            serializedObject.FindProperty(nameof(terrain.perlinParamentrs)));
            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Multiple Perlin Terrain"))
            {
                terrain.MultiplePerlinTerrain();
            }
            if (GUILayout.Button("Generate"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }
    }
 void DrawSimple()
 {
     reorderable = EditorGUILayout.Toggle("Reorderable", reorderable);
     tableState  = GUITableLayout.DrawTable(
         tableState,
         serializedObject.FindProperty("simpleObjects"),
         GUITableOption.Reorderable(reorderable));
 }
Example #8
0
    void DrawCustomProperties()
    {
        SerializedObject serializedObject = new SerializedObject(SimpleExample.Instance);

        tableState = GUITableLayout.DrawTable(tableState, serializedObject.FindProperty("simpleObjects"), new List <string>()
        {
            "floatProperty", "objectProperty"
        });
    }
    void DrawCustomColumns()
    {
        SerializedObject      serializedObject = new SerializedObject(SimpleExample.Instance);
        List <SelectorColumn> propertyColumns  = new List <SelectorColumn>()
        {
            new SelectFromPropertyNameColumn("stringProperty", TableColumn.Title("String"), TableColumn.Width(60f)),
            new SelectFromPropertyNameColumn("floatProperty", TableColumn.Title("Float"), TableColumn.Width(50f), TableColumn.Optional(true)),
            new SelectFromPropertyNameColumn("objectProperty", TableColumn.Title("Object"), TableColumn.Width(50f), TableColumn.EnabledTitle(false), TableColumn.Optional(true)),
        };

        tableState = GUITableLayout.DrawTable(tableState, serializedObject.FindProperty("simpleObjects"), propertyColumns);
    }
    void DrawCustomColumnsWithSelector()
    {
        SerializedObject serializedObject = new SerializedObject(SimpleExample.Instance);

        List <SelectorColumn> selectorColumns = new List <SelectorColumn>()
        {
            new SelectFromFunctionColumn(prop => new LabelCell(prop.FindPropertyRelative("stringProperty").stringValue), "String", TableColumn.Width(60f)),
            new SelectFromFunctionColumn(prop => new LabelCell(prop.FindPropertyRelative("floatProperty").floatValue.ToString()), "Float", TableColumn.Width(50f), TableColumn.Optional(true)),
            new SelectFromFunctionColumn(prop => new LabelCell(prop.FindPropertyRelative("objectProperty").objectReferenceValue.name), "Object", TableColumn.Width(110f), TableColumn.EnabledTitle(false), TableColumn.Optional(true)),
        };

        tableState = GUITableLayout.DrawTable(tableState, serializedObject.FindProperty("simpleObjects"), selectorColumns);
    }
Example #11
0
    public override void OnInspectorGUI()
    {
        GUILayout.Label("Default display", EditorStyles.boldLabel);

        base.OnInspectorGUI();

        GUILayout.Space(20f);

        GUILayout.Label("Table display", EditorStyles.boldLabel);

        tableState = GUITableLayout.DrawTable(tableState, serializedObject.FindProperty("simpleObjects"));

        GUILayout.Space(20f);
    }
Example #12
0
    private void DrawObjectsTable()
    {
        var serializedObject = new SerializedObject(AdvancedExample.Instance);

        var columns = new List <TableColumn>
        {
            new TableColumn("Name", TableColumn.Width(60f)),
            new TableColumn("Prefab", TableColumn.Width(50f), TableColumn.EnabledCells(false),
                            TableColumn.Optional(true)),
            new TableColumn("Type", TableColumn.Width(50f), TableColumn.Optional(true)),
            new TableColumn("Health", TableColumn.Width(50f)),
            new TableColumn("Speed", TableColumn.Width(50f)),
            new TableColumn("Color", TableColumn.Width(50f), TableColumn.Optional(true)),
            new TableColumn("Can Swim", TableColumn.Width(30f), TableColumn.Optional(true)),
            new TableColumn("Spawners", TableColumn.Width(450f), TableColumn.Optional(true)),
            new TableColumn("Intro (shared by type)", TableColumn.Width(110f), TableColumn.Optional(true)),
            new TableColumn("Instantiation", TableColumn.Width(110f), TableColumn.Optional(true))
        };

        var rows = new List <List <TableCell> >();

        var targetObject = (AdvancedExample)serializedObject.targetObject;

        for (var i = 0; i < targetObject.enemies.Count; i++)
        {
            var enemy         = targetObject.enemies[i];
            var sentenceIndex = targetObject.introSentences.FindIndex(s => s.enemyType == enemy.type);
            rows.Add(new List <TableCell>
            {
                new LabelCell(enemy.name),
                new PropertyCell(serializedObject, string.Format("enemies.Array.data[{0}]", i)),
                new PropertyCell(new SerializedObject(enemy), "type"),
                new PropertyCell(new SerializedObject(enemy), "health"),
                new PropertyCell(new SerializedObject(enemy), "speed"),
                new PropertyCell(new SerializedObject(enemy), "color"),
                new PropertyCell(new SerializedObject(enemy), "canSwim"),
                new SpawnersCell(new SerializedObject(enemy), "spawnersMask"),
                new PropertyCell(serializedObject,
                                 string.Format("introSentences.Array.data[{0}].sentence", sentenceIndex)),
                new ActionCell("Instantiate", () => enemy.Instantiate())
            });
        }

        tableState = GUITableLayout.DrawTable(tableState, columns, rows);
    }
    void DrawObjectsTable()
    {
        SerializedObject serializedObject = new SerializedObject(AdvancedExample.Instance);
        AdvancedExample  targetObject     = (AdvancedExample)serializedObject.targetObject;

        List <SelectorColumn> columns = new List <SelectorColumn> ();

        columns.Add(new SelectObjectReferenceColumn(TableColumn.Title("Enemy Prefab"), TableColumn.Width(75f), TableColumn.EnabledCells(false), TableColumn.Optional(true)));
        columns.Add(new SelectFromPropertyNameColumn("type", TableColumn.Width(50f), TableColumn.Optional(true)));
        columns.Add(new SelectFromPropertyNameColumn("health", TableColumn.Width(50f)));
        columns.Add(new SelectFromPropertyNameColumn("speed", TableColumn.Width(50f)));
        columns.Add(new SelectFromPropertyNameColumn("color", TableColumn.Width(50f), TableColumn.Optional(true)));
        columns.Add(new SelectFromPropertyNameColumn("canSwim", TableColumn.Title("Swim"), TableColumn.Width(35f), TableColumn.Optional(true)));
        columns.Add(new SelectFromFunctionColumn(
                        sp => new SpawnersCell(new SerializedObject(sp.objectReferenceValue), "spawnersMask"),
                        TableColumn.Title("Spawners"),
                        TableColumn.Width(80f),
                        TableColumn.Optional(true)));
        columns.Add(new SelectFromFunctionColumn(
                        sp =>
        {
            Enemy enemy       = (Enemy)sp.objectReferenceValue;
            int sentenceIndex = targetObject.introSentences.FindIndex(s => s.enemyType == enemy.type);
            return(new PropertyCell(serializedObject, string.Format("introSentences.Array.data[{0}].sentence", sentenceIndex)));
        },
                        TableColumn.Title("Intro (shared by type)"),
                        TableColumn.Width(150f),
                        TableColumn.Optional(true)));
        columns.Add(new SelectFromFunctionColumn(
                        sp =>
        {
            Enemy enemy = (Enemy)sp.objectReferenceValue;
            return(new ActionCell("Instantiate", () => enemy.Instantiate()));
        },
                        TableColumn.Title("Instantiation"),
                        TableColumn.Width(110f),
                        TableColumn.Optional(true)));

        tableState = GUITableLayout.DrawTable(tableState, serializedObject.FindProperty("enemies"), columns);
    }
    void Vegetation()
    {
        showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation");

        if (showVegetation)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Vegetation", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxTrees, 0, 10000, "Max Trees");
            EditorGUILayout.IntSlider(treeSpacing, 2, 20, "Tree Spacing");

            vegetationTable = GUITableLayout.DrawTable(
                vegetationTable, vegetation, GUITableOption.Reorderable(true));

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("+"))
            {
                terrain.AddNewVegetation();
            }

            if (GUILayout.Button("-"))
            {
                terrain.RemoveVegetation();
            }

            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply Vegetation"))
            {
                terrain.PlantVegetation();
            }

            if (GUILayout.Button("Clear Vegetation"))
            {
                terrain.ClearVegetation();
            }
        }
    }
Example #15
0
    private void VegetationGUI(CustomTerrain terrain)
    {
        showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation");
        if (showVegetation)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Vegetation", EditorStyles.boldLabel);

            EditorGUILayout.IntSlider(maxTrees, 0, 10000, new GUIContent("Max Trees"));
            EditorGUILayout.IntSlider(treeSpacing, 2, 20, new GUIContent("Tree Spacing"));


            vegMapTable = GUITableLayout.DrawTable(vegMapTable,
                                                   serializedObject.FindProperty(nameof(terrain.vegetations)));
            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.ADdNewVegetation();
            }

            if (GUILayout.Button("-"))
            {
                terrain.RemoveVegetation();
            }

            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply"))
            {
                terrain.PlanVegetation();
            }

            ;
        }
    }
    void Detail()
    {
        showDetail = EditorGUILayout.Foldout(showDetail, "Detail");

        if (showDetail)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Detail", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Max Details"));
            EditorGUILayout.IntSlider(detailSpacing, 1, 20, new GUIContent("Detail Spacing"));

            detailTable = GUITableLayout.DrawTable(detailTable, details, GUITableOption.Reorderable(true));

            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("+"))
            {
                terrain.AddNewDetails();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveDetails();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply Details"))
            {
                terrain.PlantDetails();
            }

            if (GUILayout.Button("Clear Details"))
            {
                terrain.ClearDetails();
            }
        }
    }
    void SplatMaps()
    {
        showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps");

        if (showSplatMaps)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Splat Maps", EditorStyles.boldLabel);

            //EditorGUILayout.Slider(splatOffset, 0f, 1f, "Offset");
            //EditorGUILayout.Slider(splatNoiseXScale, 0f, 1f, "Noise Scale X");
            //EditorGUILayout.Slider(splatNoiseYScale, 0f, 1f, "Noise Y Scale");
            //EditorGUILayout.Slider(splatNoiseMultiplier, 0f, 1f, "Noise Multipler");

            splatHeightsTable = GUITableLayout.DrawTable(
                splatHeightsTable, splatHeights, GUITableOption.Reorderable(true));

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("+"))
            {
                terrain.AddNewSplatHeight();
            }

            if (GUILayout.Button("-"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply SplatMaps"))
            {
                terrain.SplatMaps();
            }
        }
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        CustomTerrain terrain = (CustomTerrain)target;

        showRandom = EditorGUILayout.Foldout(showRandom, "Random");
        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            if (GUILayout.Button("Random Heights"))
            {
                terrain.RandomTerrain();
            }
        }

        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights");
        if (showLoadHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            if (GUILayout.Button("Load Texture"))
            {
                terrain.LoadTexture();
            }
        }

        showPerlin = EditorGUILayout.Foldout(showPerlin, "Perlin");
        if (showPerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("X and Y Scale", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000000, new GUIContent("X Offset"));
            EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000000, new GUIContent("Y Offset"));
            EditorGUILayout.Slider(perlinXScale, 0, .01f, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinYScale, 0, .01f, new GUIContent("Y Scale"));
            if (GUILayout.Button("Draw"))
            {
                terrain.Perlin();
            }
        }

        showFBM = EditorGUILayout.Foldout(showFBM, "Fractal Brownian Motion");
        if (showFBM)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Config", EditorStyles.boldLabel);

            EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000000, new GUIContent("X Offset"));
            EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000000, new GUIContent("Y Offset"));
            EditorGUILayout.IntSlider(oct, 2, 15, new GUIContent("Oct"));
            EditorGUILayout.Slider(persistance, 0, 10, new GUIContent("Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 2, new GUIContent("Height Scale"));
            EditorGUILayout.Slider(perlinXScale, 0, .01f, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinYScale, 0, .01f, new GUIContent("Y Scale"));
            if (GUILayout.Button("Draw"))
            {
                terrain.FractalBrownianMotion();
            }
        }

        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple perlin");
        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Config", EditorStyles.boldLabel);

            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, serializedObject.FindProperty("perlinParameters"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("Remove selected"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Draw"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }



        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");
        if (showVoronoi)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("mountains", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(voronoiType);
            EditorGUILayout.IntSlider(voronoipeakCount, 1, 10, new GUIContent("peak count"));
            EditorGUILayout.Slider(voronoiMinMountainHeight, 0.0001f, 1.9999f);
            EditorGUILayout.Slider(voronoiMaxMountainHeight, 0.0002f, 2);
            EditorGUILayout.Slider(voronoiDropOff, 0, 10, new GUIContent("drop off"));
            EditorGUILayout.Slider(voronoiFallOff, 0, 10, new GUIContent("fall off"));
            if (GUILayout.Button("Draw"))
            {
                terrain.Voronoi();
            }
        }

        showMidPointDisplacement = EditorGUILayout.Foldout(showMidPointDisplacement, "Mid-Point Displacement");
        if (showMidPointDisplacement)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("mid-point displacement", EditorStyles.boldLabel);
            EditorGUILayout.Slider(midPointHeightMax, 0, 10);
            EditorGUILayout.Slider(midPointHeightMin, -10, 0);
            EditorGUILayout.Slider(midPointRoughness, 1, 10, new GUIContent("smoothness"));
            EditorGUILayout.Slider(midPointHeightDampening, 0, 4, new GUIContent("peak dampening"));
            if (GUILayout.Button("MPD"))
            {
                terrain.MidPointDisplacement();
            }
        }

        showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth");
        if (showSmooth)
        {
            EditorGUILayout.IntSlider(smoothAmount, 1, 10, new GUIContent("smooth x amount of times"));
            if (GUILayout.Button("Smooth"))
            {
                terrain.Smooth();
            }
        }

        showSplatMap = EditorGUILayout.Foldout(showSplatMap, "Splat Map");
        if (showSplatMap)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Colors", EditorStyles.boldLabel);

            EditorGUILayout.Slider(splatOffset, 0, 0.1f);
            EditorGUILayout.Slider(splatNoiseXScale, 0.001f, 1);
            EditorGUILayout.Slider(splatNoiseYScale, 0.001f, 1);
            EditorGUILayout.Slider(splatNoiseScale, 0, 1);
            splatHeightsTable = GUITableLayout.DrawTable(splatHeightsTable, serializedObject.FindProperty("splatHeights"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddToSplatMap();
            }
            if (GUILayout.Button("Remove selected"))
            {
                terrain.RemoveFromSplatMap();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Paint"))
            {
                terrain.SplatMaps();
            }
        }

        showVegetation = EditorGUILayout.Foldout(showVegetation, "vegetation");
        if (showVegetation)
        {
            EditorGUILayout.IntSlider(vegetationMaximumTrees, 1, 1000);
            EditorGUILayout.IntSlider(vegetationTreeSpacing, 1, 1000);

            vegeatationHeightsTable = GUITableLayout.DrawTable(vegeatationHeightsTable, serializedObject.FindProperty("vegetationHeights"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddToVegetation();
            }

            if (GUILayout.Button("Plant"))
            {
                terrain.RemoveFromVegetation();
            }
        }


        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        EditorGUILayout.PropertyField(resetTerrain, new GUIContent("Reset terrain after update"));
        if (GUILayout.Button("Make Jagged"))
        {
            terrain.MakeJagged();
        }
        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }

        serializedObject.ApplyModifiedProperties();
    }
Example #19
0
    public override void OnInspectorGUI()
    {
        int viewWidth = (int)(EditorGUIUtility.currentViewWidth - 100);

        serializedObject.Update();

        CustomTerrain terrain = (CustomTerrain)target;

        // scrollbar starting code
        Rect r = EditorGUILayout.BeginVertical();

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height));
        EditorGUI.indentLevel++;

        EditorGUILayout.PropertyField(resetTerrain);

        showRandom = EditorGUILayout.Foldout(showRandom, "Random");
        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            if (GUILayout.Button("Random Heights"))
            {
                terrain.RandomTerrain();
            }
        }

        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights");
        if (showLoadHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            if (GUILayout.Button("Load Texture"))
            {
                terrain.LoadTexture();
            }
        }

        showPerlin = EditorGUILayout.Foldout(showPerlin, "Single Perlin Noise");
        if (showPerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights with Perlin Noise", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinXScale, 0, 1, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinYScale, 0, 1, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("X Offset"));
            EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("Y Offset"));
            EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(perlinPersistence, 0.1f, 10, new GUIContent("Persistence"));
            EditorGUILayout.Slider(perlinFrequencyMultiplier, 2, 10, new GUIContent("Frequency Multiplier"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale"));
            if (GUILayout.Button("Perlin Noise"))
            {
                terrain.Perlin();
            }
        }

        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perlin Noise");
        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Multiple Perlin Noise", EditorStyles.boldLabel);
            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, perlinParameters);

            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Multiple Perlin"))
            {
                terrain.MultiplePerlin();
            }
        }

        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");
        if (showVoronoi)
        {
            EditorGUILayout.IntSlider(voronoiPeakCount, 1, 10, new GUIContent("Peak Count"));
            EditorGUILayout.Slider(voronoiFalloff, 0, 10, new GUIContent("Falloff"));
            EditorGUILayout.Slider(voronoiDropoff, 0, 10, new GUIContent("Dropoff"));
            EditorGUILayout.Slider(voronoiMinHeight, 0, 1, new GUIContent("Min Height"));
            EditorGUILayout.Slider(voronoiMaxHeight, 0, 1, new GUIContent("Max Height"));
            EditorGUILayout.PropertyField(voronoiType);
            if (GUILayout.Button("Voronoi"))
            {
                terrain.Voronoi();
            }
        }

        showMidPointDisplacement = EditorGUILayout.Foldout(showMidPointDisplacement, "Mid Point Displacement");
        if (showMidPointDisplacement)
        {
            EditorGUILayout.Slider(mpdMinHeight, -10, 0, new GUIContent("Min Height"));
            EditorGUILayout.Slider(mpdMaxHeight, 0, 10, new GUIContent("Max Height"));
            EditorGUILayout.Slider(mpdRoughness, 0, 5, new GUIContent("Roughness"));
            EditorGUILayout.Slider(mpdHeightDampenerPower, 0, 1, new GUIContent("Height Dampener Power"));
            if (GUILayout.Button("MPD"))
            {
                terrain.MidPointDisplacement();
            }
        }

        showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps");
        if (showSplatMaps)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Splat Maps", EditorStyles.boldLabel);
            splatMapTable = GUITableLayout.DrawTable(splatMapTable, splatHeights);

            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewSplatHeight();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply SplatMaps"))
            {
                terrain.ApplySplatMaps();
            }
        }

        showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation");
        if (showVegetation)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Vegetation", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxTrees, 0, 10000, new GUIContent("Maximum Trees"));
            EditorGUILayout.IntSlider(treeSpacing, 2, 20, new GUIContent("Tree Spacing"));
            vegetationTable = GUITableLayout.DrawTable(vegetationTable, vegetation);

            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewVegetation();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveVegetation();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Vegetation"))
            {
                terrain.ApplyVegetation();
            }
        }

        showDetails = EditorGUILayout.Foldout(showDetails, "Details");
        if (showDetails)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Details", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Maximum Details"));
            EditorGUILayout.IntSlider(detailSpacing, 1, 20, new GUIContent("Detail Spacing"));
            detailsTable = GUITableLayout.DrawTable(detailsTable, details);

            // sync unity's detail distance with max details value from slider
            // so we can see all the details while developing. may want to dial back if framerate
            // is affected
            terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue;

            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewDetails();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveDetails();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Details"))
            {
                terrain.ApplyDetails();
            }
        }

        showWater = EditorGUILayout.Foldout(showWater, "Water");
        if (showWater)
        {
            EditorGUILayout.Slider(waterHeight, 0, 1, new GUIContent("Water Height"));
            EditorGUILayout.PropertyField(waterGameObject);
            if (GUILayout.Button("Apply Water"))
            {
                terrain.ApplyWater();
            }

            EditorGUILayout.PropertyField(shorelineMaterial);
            if (GUILayout.Button("Draw Shoreline"))
            {
                terrain.DrawShoreline();
            }
        }

        showErosion = EditorGUILayout.Foldout(showErosion, "Erosion");
        if (showErosion)
        {
            EditorGUILayout.PropertyField(erosionType);
            EditorGUILayout.Slider(erosionStrength, 0, 1, new GUIContent("Erosion Strength"));
            EditorGUILayout.Slider(erosionAmount, 0, 1, new GUIContent("Erosion Amount"));
            EditorGUILayout.IntSlider(droplets, 0, 500, new GUIContent("Droplets"));
            EditorGUILayout.Slider(solubility, 0.001f, 1, new GUIContent("Solubility"));
            EditorGUILayout.IntSlider(springsPerDroplet, 0, 20, new GUIContent("Springs per River"));
            EditorGUILayout.IntSlider(erosionSmoothAmount, 0, 10, new GUIContent("Smooth Amount"));

            if (GUILayout.Button("Erode"))
            {
                terrain.Erode();
            }
        }

        showClouds = EditorGUILayout.Foldout(showClouds, "Clouds");
        if (showClouds)
        {
            EditorGUILayout.PropertyField(numberOfClouds, new GUIContent("Number of Clouds"));
            EditorGUILayout.PropertyField(particlesPerCloud, new GUIContent("Particles per Cloud"));
            EditorGUILayout.PropertyField(cloudParticleSize, new GUIContent("Cloud Particle Size"));
            EditorGUILayout.PropertyField(cloudMinSize, new GUIContent("Min Size"));
            EditorGUILayout.PropertyField(cloudMaxSize, new GUIContent("Max Size"));
            EditorGUILayout.PropertyField(cloudMaterial, new GUIContent("Cloud Material"));
            EditorGUILayout.PropertyField(cloudShadowMaterial, new GUIContent("Cloud Shadow Material"));
            EditorGUILayout.PropertyField(cloudColor, new GUIContent("Color"));
            EditorGUILayout.PropertyField(cloudLiningColor, new GUIContent("Lining"));
            EditorGUILayout.PropertyField(cloudMinSpeed, new GUIContent("Min Speed"));
            EditorGUILayout.PropertyField(cloudMaxSpeed, new GUIContent("Max Speed"));
            EditorGUILayout.PropertyField(cloudDistanceTraveled, new GUIContent("Distance Traveled"));

            if (GUILayout.Button("Generate Clouds"))
            {
                terrain.GenerateClouds();
            }
        }

        showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth Terrain");
        if (showSmooth)
        {
            EditorGUILayout.IntSlider(smoothAmount, 1, 10, new GUIContent("Smooth Amount"));
            if (GUILayout.Button("Smooth"))
            {
                terrain.SmoothStandalone();
            }
        }



        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }

        showHeightMap = EditorGUILayout.Foldout(showHeightMap, "Height Map");
        if (showHeightMap)
        {
            // begin centered row
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(heightMapTexture, GUILayout.Width(viewWidth), GUILayout.Height(viewWidth));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            // end centered row

            // begin centered row
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Refresh", GUILayout.Width(viewWidth)))
            {
                float[,] heights = terrain.terrainData.GetHeights(0, 0, terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight);
                LoadArrayToTexture2D(heightMapTexture, heights);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            // end centered row
        }

        // scrollbar ending code
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
    }
Example #20
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        CustomTerrain terrain = (CustomTerrain)target;

        //Scrollbar Starting Code
        Rect r = EditorGUILayout.BeginVertical();

        scrollPos =
            EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height));
        EditorGUI.indentLevel++;


        EditorGUILayout.PropertyField(resetTerrain);
        showRandom = EditorGUILayout.Foldout(showRandom, "Random");
        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            if (GUILayout.Button("Random Heights"))
            {
                terrain.RandomTerrain();
            }
        }

        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights");
        if (showLoadHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            if (GUILayout.Button("Load Texture"))
            {
                terrain.LoadTexture();
            }
        }

        showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Single Perlin Noise");
        if (showPerlinNoise)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Perlin Noise", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinXScale, 0, 1, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinYScale, 0, 1, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("Offset X"));
            EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("Offset Y"));
            EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(perlinPersistance, 0.1f, 10, new GUIContent("Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale"));

            if (GUILayout.Button("Perlin"))
            {
                terrain.Perlin();
            }
        }

        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perlin Noise");
        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Mulitple Perlin Noise", EditorStyles.boldLabel);
            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable,
                                                            serializedObject.FindProperty("perlinParameters"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Multiple Perlin"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }

        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");
        if (showVoronoi)
        {
            EditorGUILayout.IntSlider(voronoiPeaks, 1, 10, new GUIContent("Peak Count"));
            EditorGUILayout.Slider(voronoiFallOff, 0, 10, new GUIContent("Falloff"));
            EditorGUILayout.Slider(voronoiDropOff, 0, 10, new GUIContent("Dropoff"));
            EditorGUILayout.Slider(voronoiMinHeight, 0, 1, new GUIContent("Min Height"));
            EditorGUILayout.Slider(voronoiMaxHeight, 0, 1, new GUIContent("Max Height"));
            EditorGUILayout.PropertyField(voronoiType);
            if (GUILayout.Button("Voronoi"))
            {
                terrain.Voronoi();
            }
        }

        showMPD = EditorGUILayout.Foldout(showMPD, "Midpoint Displacement");
        if (showMPD)
        {
            EditorGUILayout.PropertyField(MPDheightMin);
            EditorGUILayout.PropertyField(MPDheightMax);
            EditorGUILayout.PropertyField(MPDheightDampenerPower);
            EditorGUILayout.PropertyField(MPDroughness);
            if (GUILayout.Button("MPD"))
            {
                terrain.MidpointDisplacement();
            }
        }

        showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps");
        if (showSplatMaps)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Splat Maps", EditorStyles.boldLabel);

            /*EditorGUILayout.Slider(splatOffset, 0, 0.1f, new GUIContent("Offset"));
             * EditorGUILayout.Slider(splatNoiseXScale, 0.001f, 1, new GUIContent("Noise X Scale"));
             * EditorGUILayout.Slider(splatNoiseYScale, 0.001f, 1, new GUIContent("Noise Y Scale"));
             * EditorGUILayout.Slider(splatNoiseScaler, 0, 1, new GUIContent("Noise Scaler"));*/
            splatMapTable = GUITableLayout.DrawTable(splatMapTable,
                                                     serializedObject.FindProperty("splatHeights"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewSplatHeight();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply SplatMaps"))
            {
                terrain.SplatMaps();
            }
        }

        showVeg = EditorGUILayout.Foldout(showVeg, "Vegetation");
        if (showVeg)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Vegetation", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxTrees, 0, 10000, new GUIContent("Maximum Trees"));
            EditorGUILayout.IntSlider(treeSpacing, 2, 20, new GUIContent("Trees Spacing"));
            vegMapTable = GUITableLayout.DrawTable(vegMapTable,
                                                   serializedObject.FindProperty("vegetation"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewVegetaion();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveVegetaion();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Vegetation"))
            {
                terrain.PlantVegetaion();
            }
        }

        showDetail = EditorGUILayout.Foldout(showDetail, "Details");
        if (showDetail)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Detail", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Maximum Details"));
            EditorGUILayout.IntSlider(detailSpacing, 1, 20, new GUIContent("Detail Spacing"));
            detailMapTable = GUITableLayout.DrawTable(detailMapTable,
                                                      serializedObject.FindProperty("details"));

            terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue;

            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("+"))
            {
                terrain.AddNewDetails();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveDetails();
            }

            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Details"))
            {
                terrain.AddDetails();
            }
        }

        showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth Terrain");
        if (showSmooth)
        {
            EditorGUILayout.IntSlider(smoothAmount, 1, 10, new GUIContent("smoothAmount"));
            if (GUILayout.Button("Smooth"))
            {
                terrain.SmoothTerrain();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }

        // Display Height Map
        showHeightMap = EditorGUILayout.Foldout(showHeightMap, "Height Map");
        if (showHeightMap)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            int hmtSize = (int)(EditorGUIUtility.currentViewWidth - 100);
            GUILayout.Label(hmTexture, GUILayout.Width(hmtSize), GUILayout.Height(hmtSize));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Refresh", GUILayout.Width(hmtSize)))
            {
                float[,] heightMap = terrain.terrainData.GetHeights(0, 0,
                                                                    terrain.terrainData.heightmapWidth,
                                                                    terrain.terrainData.heightmapHeight);


                for (int y = 0; y < terrain.terrainData.heightmapHeight; ++y)
                {
                    for (int x = 0; x < terrain.terrainData.heightmapWidth; ++x)
                    {
                        hmTexture.SetPixel(x, y, new Color(heightMap[x, y],
                                                           heightMap[x, y],
                                                           heightMap[x, y], 1));
                    }
                }
                hmTexture.Apply();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }

        //Scrollbar ending code
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
    }
Example #21
0
    // Updates the Editor GUI
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        CustomTerrain terrain = (CustomTerrain)target;

        GUILayout.Label("Terrain generation", EditorStyles.boldLabel);

        //Random Terrain
        showRandom = EditorGUILayout.Foldout(showRandom, "Random");
        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights by Random Values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            if (GUILayout.Button("Random Heights"))
            {
                terrain.RandomTerrain();
            }
        }

        //Texture Terrain
        showTexture = EditorGUILayout.Foldout(showTexture, "Texture");
        if (showTexture)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights by Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            if (GUILayout.Button("Load Texture"))
            {
                terrain.TextureTerrain();
            }
        }

        //PerlinNoise Terrain
        showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Perlin Noise");
        if (showPerlinNoise)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights by Perlin Noise", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinScaleX, 0, 0.05f, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinScaleY, 0, 0.05f, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinOffsetX, 0, 1000, new GUIContent("X Offset"));
            EditorGUILayout.IntSlider(perlinOffsetY, 0, 1000, new GUIContent("Y Offset"));
            EditorGUILayout.IntSlider(perlinOctaves, 0, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(perlinPersistance, 0.1f, 10, new GUIContent("Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("HeightScale"));
            EditorGUILayout.Slider(perlinFrequency, 0, 3, new GUIContent("Frequency"));

            if (GUILayout.Button("Generate"))
            {
                terrain.PerlinNoiseTerrain();
            }
        }

        //Multiple PerlinNoise Terrain
        showMultiplePerlinNoise = EditorGUILayout.Foldout(showMultiplePerlinNoise, "Multiple Perlin Noise");
        if (showMultiplePerlinNoise)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights by Multiple Perlin Noises", EditorStyles.boldLabel);

            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, serializedObject.FindProperty("perlinParamList"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("Remove"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Generate"))
            {
                terrain.MultiplePerlinNoiseTerrain();
            }
        }

        //Voronoi Terrain
        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");
        if (showVoronoi)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set New Voronoi Point", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(voronoiPeakCount, 1, 10, new GUIContent("Peaks"));
            EditorGUILayout.Slider(voronoiFallOff, 0.1f, 10, new GUIContent("Fall off"));
            EditorGUILayout.Slider(voronoiDropOff, 0.1f, 10, new GUIContent("Drop off"));
            EditorGUILayout.Slider(voronoiMinHeight, 0, 1, new GUIContent("Min Height"));
            EditorGUILayout.Slider(voronoiMaxHeight, 0, 1, new GUIContent("Max Height"));
            EditorGUILayout.PropertyField(voronoiType);
            if (GUILayout.Button("Generate"))
            {
                terrain.VoronoiTerrain();
            }
        }

        //MidPointDisplacement Terrain
        showmMPD = EditorGUILayout.Foldout(showmMPD, "Mid Point Displacement");
        if (showmMPD)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Mid Point Displacement", EditorStyles.boldLabel);
            EditorGUILayout.Slider(mpdHeightMin, -10, 5, "Min Height");
            EditorGUILayout.Slider(mpdHeightMax, -5, 10, "Max Height");
            EditorGUILayout.Slider(mpdHeightDampener, 0, 5, "Dampener");
            EditorGUILayout.Slider(mpdRoughness, 0, 5, "Roughness");
            if (GUILayout.Button("Generate"))
            {
                terrain.MPDTerrain();
            }
        }

        //MidPointDisplacement Terrain
        showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth");
        if (showSmooth)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Smooth Terrain", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(smoothIterations, 1, 10, "Iterations");
            if (GUILayout.Button("Smooth"))
            {
                terrain.SmoothTerrain();
            }
        }

        //Erosion
        showErosion = EditorGUILayout.Foldout(showErosion, "Erosion");
        if (showErosion)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Erode Terrain", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(erosionType);
            EditorGUILayout.IntSlider(erosionDroplets, 100, 6000, "Droplets");
            EditorGUILayout.IntSlider(erosionSpringsPerDroplet, 1, 5, "Springs");
            EditorGUILayout.Slider(erosionStrength, 0.001f, 0.1f, "Strength");
            EditorGUILayout.Slider(erosionSolubility, 0.0001f, 0.1f, "Solubility");
            if (GUILayout.Button("Erode"))
            {
                terrain.Erode();
            }
        }

        GUILayout.Label("Terrain texturing", EditorStyles.boldLabel);

        // SplatMaps
        showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps");
        if (showSplatMaps)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Splat Maps", EditorStyles.boldLabel);

            EditorGUILayout.Slider(splatOffset, 0f, 0.1f, new GUIContent("Offset"));
            EditorGUILayout.Slider(splatNoiseScale, 0f, 0.1f, new GUIContent("Noise Scale"));
            EditorGUILayout.Slider(splatNoiseX, 0f, 2f, new GUIContent("Noise X"));
            EditorGUILayout.Slider(splatNoiseY, 0f, 2f, new GUIContent("Noise Y"));

            splatMapTable = GUITableLayout.DrawTable(splatMapTable, serializedObject.FindProperty("splatHeights"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add"))
            {
                terrain.AddNewSplatHeight();
            }
            if (GUILayout.Button("Remove"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Splatmaps"))
            {
                terrain.SplatMaps();
            }
        }

        GUILayout.Label("Details", EditorStyles.boldLabel);
        showWater = EditorGUILayout.Foldout(showWater, "Water");
        if (showWater)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Water", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(waterObject);
            EditorGUILayout.PropertyField(shoreLineMaterial);
            EditorGUILayout.Slider(waterHeight, 0, 1, "Water Height");
            if (GUILayout.Button("River"))
            {
                terrain.River();
            }
            if (GUILayout.Button("Set Water"))
            {
                terrain.SetWater();
                //terrain.SetShoreline();
            }
        }

        showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation");
        if (showVegetation)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Vegetation", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(vegetationMaxTrees, 100, 10000, "Max Trees");
            EditorGUILayout.IntSlider(vegetationTreeSpacing, 1, 50, "Tree Spacing");

            vegetationRules = GUITableLayout.DrawTable(vegetationRules, serializedObject.FindProperty("vegetationRules"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add"))
            {
                terrain.AddNewVegetationMesh();
            }
            if (GUILayout.Button("Remove"))
            {
                terrain.RemoveVegetationMesh();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Vegetation"))
            {
                terrain.SetVegetation();
            }
        }

        //Reset Terrain
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        EditorGUILayout.PropertyField(resetTerrain);

        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }
        if (GUILayout.Button("Generate Random Terrain"))
        {
            terrain.GenerateRandomTerrain();
        }

        serializedObject.ApplyModifiedProperties();
    }
Example #22
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        CustomTerrain terrain = (CustomTerrain)target;

        EditorGUILayout.PropertyField(resetTerrain);

        showRandom = EditorGUILayout.Foldout(showRandom, "Random");
        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            if (GUILayout.Button("Random Heights"))
            {
                terrain.RandomTerrain();
            }
        }

        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights");
        if (showLoadHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            if (GUILayout.Button("Load Texture"))
            {
                terrain.LoadTexture();
            }
        }

        showPerlin = EditorGUILayout.Foldout(showPerlin, "Single Perlin Noise");
        if (showPerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Perlin Noise Heights", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinXScale, 0f, 0.1f, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinYScale, 0f, 0.1f, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("X Offset"));
            EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("Y Offset"));
            // Fractal Brownian Motion additions
            EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(perlinPersistance, 0.1f, 10, new GUIContent("Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale"));
            if (GUILayout.Button("Perlin Noise"))
            {
                terrain.Perlin();
            }
        }

        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perlin Noise");
        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Multiple Perlin Noise", EditorStyles.boldLabel);
            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable,
                                                            perlinParameters);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Multiple Perlin"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }

        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");
        if (showVoronoi)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            EditorGUILayout.IntSlider(peakCount, 1, 10, new GUIContent("Peak Count"));
            EditorGUILayout.Slider(fallOff, 0f, 10f, new GUIContent("Falloff"));
            EditorGUILayout.Slider(dropOff, 0f, 10f, new GUIContent("Dropoff"));
            EditorGUILayout.Slider(minHeight, 0f, 1f, new GUIContent("Min Height"));
            EditorGUILayout.Slider(maxHeight, 0f, 1f, new GUIContent("Max Height"));
            EditorGUILayout.PropertyField(voronoiType);

            if (GUILayout.Button("Voronoi"))
            {
                terrain.Voronoi();
            }
        }

        showMPD = EditorGUILayout.Foldout(showMPD, "Midpoint Displacement");
        if (showMPD)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            EditorGUILayout.PropertyField(mdpMinHeight, new GUIContent("Min Height"));
            EditorGUILayout.PropertyField(mdpMaxHeight, new GUIContent("Max Height"));
            EditorGUILayout.PropertyField(roughness, new GUIContent("Roughness"));
            EditorGUILayout.PropertyField(heightDampenerPower, new GUIContent("Height Damp. Pow"));

            if (GUILayout.Button("MPD"))
            {
                terrain.MidpointDisplacement();
            }
        }

        showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps");
        if (showSplatMaps)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Splat Maps", EditorStyles.boldLabel);
            splatMapTable = GUITableLayout.DrawTable(splatMapTable,
                                                     serializedObject.FindProperty("splatHeights"));
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewSplatHeight();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply SplatMaps"))
            {
                terrain.SplatMaps();
            }
        }

        showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation");
        if (showVegetation)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            EditorGUILayout.IntSlider(maxTrees, 100, 10000, new GUIContent("Max Trees"));
            EditorGUILayout.IntSlider(treeSpacing, 1, 100, new GUIContent("Tree Spacing"));
            GUILayout.Label("Vegetation", EditorStyles.boldLabel);
            vegetationTable = GUITableLayout.DrawTable(vegetationTable,
                                                       serializedObject.FindProperty("vegetation"));
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewVegetation();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveVegetation();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Vegetation"))
            {
                terrain.PlantVegetation();
            }
        }

        showDetail = EditorGUILayout.Foldout(showDetail, "Detail");
        if (showDetail)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            EditorGUILayout.IntSlider(maxDetails, 100, 10000, new GUIContent("Max Distance"));
            EditorGUILayout.IntSlider(detailSpacing, 1, 100, new GUIContent("Detail Spacing"));
            GUILayout.Label("Details", EditorStyles.boldLabel);
            detailsTable = GUITableLayout.DrawTable(detailsTable,
                                                    serializedObject.FindProperty("details"));

            terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue;

            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewDetail();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveDetails();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Details"))
            {
                terrain.PlaceDetails();
            }
        }

        showWater = EditorGUILayout.Foldout(showWater, "Water");
        if (showWater)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Water", EditorStyles.boldLabel);
            EditorGUILayout.Slider(waterHeight, 0f, 1.0f, new GUIContent("Water Height"));
            EditorGUILayout.PropertyField(waterGO, new GUIContent("Water GO"));

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Water"))
            {
                terrain.AddWater();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.PropertyField(shoreLineMaterial, new GUIContent("Shore Line Material"));

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Shoreline"))
            {
                terrain.DrawShoreline();
            }
            EditorGUILayout.EndHorizontal();
        }

        showErosion = EditorGUILayout.Foldout(showErosion, "Erosion");
        if (showErosion)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            EditorGUILayout.PropertyField(erosionType);
            EditorGUILayout.Slider(erosionStrength, 0f, 1.0f, new GUIContent("Erosion Strength"));
            EditorGUILayout.Slider(erosionAmount, 0f, 0.5f, new GUIContent("Erosion Amount"));
            EditorGUILayout.IntSlider(droplets, 1, 500, new GUIContent("Droplets"));
            EditorGUILayout.Slider(solubility, 0.001f, 1.0f, new GUIContent("Solubility"));
            EditorGUILayout.IntSlider(springsPerRiver, 0, 20, new GUIContent("Springs Per River"));
            EditorGUILayout.IntSlider(erosionSmoothAmount, 0, 10, new GUIContent("Smooth Amount"));

            if (GUILayout.Button("Erode"))
            {
                terrain.Erode();
            }
        }

        showClouds = EditorGUILayout.Foldout(showClouds, "Clouds");
        if (showClouds)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            EditorGUILayout.PropertyField(numClouds, new GUIContent("Number of Clouds"));
            EditorGUILayout.PropertyField(particlesPerCloud, new GUIContent("Particles Per Cloud"));
            EditorGUILayout.PropertyField(cloudStartSize, new GUIContent("Cloud Start Size"));
            EditorGUILayout.PropertyField(cloudScaleMin, new GUIContent("Scale Min"));
            EditorGUILayout.PropertyField(cloudScaleMax, new GUIContent("Scale Max"));
            EditorGUILayout.PropertyField(cloudMaterial, new GUIContent("Cloud Material"));
            EditorGUILayout.PropertyField(cloudShadowMaterial, new GUIContent("Cloud Shadow Material"));
            EditorGUILayout.PropertyField(cloudColour, new GUIContent("Colour"));
            EditorGUILayout.PropertyField(cloudLining, new GUIContent("Lining"));
            EditorGUILayout.PropertyField(cloudMinSpeed, new GUIContent("Min Speed"));
            EditorGUILayout.PropertyField(cloudMaxSpeed, new GUIContent("Max Speed"));
            EditorGUILayout.PropertyField(cloudRange, new GUIContent("Distance Travelled"));

            if (GUILayout.Button("Generate Clouds"))
            {
                terrain.GenerateClouds();
            }
        }

        showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth Terrain");
        if (showSmooth)
        {
            EditorGUILayout.IntSlider(peakCount, 1, 10, new GUIContent("Smooth Aamount"));
            if (GUILayout.Button("Smooth"))
            {
                terrain.Smooth();
            }
        }

        showHeightMap = EditorGUILayout.Foldout(showHeightMap, "Height Map");
        if (showHeightMap)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            int hmtSize = (int)(EditorGUIUtility.currentViewWidth - 100);
            GUILayout.Label(hmTexture, GUILayout.Width(hmtSize), GUILayout.Height(hmtSize));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Refresh", GUILayout.Width(hmtSize)))
            {
                float[,] heightMap = terrain.terrainData.GetHeights(0, 0,
                                                                    terrain.terrainData.heightmapWidth,
                                                                    terrain.terrainData.heightmapHeight);
                for (int y = 0; y < terrain.terrainData.heightmapHeight; y++)
                {
                    for (int x = 0; x < terrain.terrainData.heightmapWidth; x++)
                    {
                        hmTexture.SetPixel(x, y, new Color(heightMap[x, y],
                                                           heightMap[x, y],
                                                           heightMap[x, y], 1));
                    }
                }
                hmTexture.Apply();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }

        serializedObject.ApplyModifiedProperties();
    }
Example #23
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        CustomTerrain terrain = (CustomTerrain)target;

        EditorGUILayout.PropertyField(resetTerrain);

        showRandom = EditorGUILayout.Foldout(showRandom, "Random");

        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set heights randomly between values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            if (GUILayout.Button("Random Heights"))
            {
                terrain.RandomTerrain();
            }
        }
        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Height Map Texture");

        if (showLoadHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Load Height Map Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            if (GUILayout.Button("Load Texture"))
            {
                terrain.LoadHeightMapImage();
            }
        }

        showPerlin = EditorGUILayout.Foldout(showPerlin, "Perlin Noise Generator");

        if (showPerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Perlin Generator", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinNoiseXScale, 0f, 0.05f, new GUIContent("X Scale"));
            EditorGUILayout.Slider(PerlinNoiseYScale, 0f, 0.05f, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("X Offset"));
            EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("Y Offset"));
            EditorGUILayout.IntSlider(perlinOctaves, 0, 50, new GUIContent("Brownian Octaves"));
            EditorGUILayout.Slider(perlinPersistance, 0.1f, 20f, new GUIContent("Brownian Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0f, 1f, new GUIContent("Height Scale"));
            if (GUILayout.Button("Run Generator"))
            {
                terrain.PerlinNoise();
            }
        }

        showMultiPerlin = EditorGUILayout.Foldout(showMultiPerlin, "Multiple Perlin Noise Generator");

        if (showMultiPerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Multiple Perlin Generator", EditorStyles.boldLabel);

            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, serializedObject.FindProperty("perlinParameters"));
            GUILayout.Space(29);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Run Multi Perlin Generator"))
            {
                terrain.MultiPerlin();
            }
        }

        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");

        if (showVoronoi)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Voronoi Generator", EditorStyles.boldLabel);

            EditorGUILayout.Slider(voronoiFallOff, 0f, 10f, new GUIContent("Fall Off"));
            EditorGUILayout.Slider(voronoiDropOff, 0f, 10f, new GUIContent("Drop Off"));
            EditorGUILayout.Slider(voronoiMinHeight, 0f, 1f, new GUIContent("Min Height"));
            EditorGUILayout.Slider(voronoiMaxHeight, 0f, 1f, new GUIContent("Max Height"));
            EditorGUILayout.IntSlider(voronoiPeakCount, 1, 10, new GUIContent("Peak Count"));
            EditorGUILayout.PropertyField(voronoiType);
            if (GUILayout.Button("Run Voronoi"))
            {
                terrain.VeronoiLift();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }

        serializedObject.ApplyModifiedProperties();
    }
Example #24
0
    public override void OnInspectorGUI()
    {
        int wSize = (int)(EditorGUIUtility.currentViewWidth - 100);

        serializedObject.Update();

        CustomTerrain terrain = (CustomTerrain)target;

        // Scrollbar starting code
        Rect r = EditorGUILayout.BeginVertical();

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height));
        EditorGUI.indentLevel++;

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showRandom = EditorGUILayout.Foldout(showRandom, "RandomGenProps");
        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Height Randomly Between Two Values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            if (GUILayout.Button("Gen Random Heights"))
            {
                terrain.RandomTerrain();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "ImageGenProps");
        if (showLoadHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Load Height From Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            if (GUILayout.Button("Load Texture Heights"))
            {
                terrain.LoadTexture();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showPerlin = EditorGUILayout.Foldout(showPerlin, "PerlinGenProps");
        if (showPerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Height Based On Perlin Noise", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinXScale, 0.0f, 1.0f, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinYScale, 0.0f, 1.0f, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("X Offset"));
            EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("Y Offset"));
            EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(perlinPersistance, 0.1f, 10.0f, new GUIContent("Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0.0f, 1.0f, new GUIContent("Perlin Height Scale"));
            if (GUILayout.Button("Gen Perlin Heights"))
            {
                terrain.Perlin();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showMultiPerlin = EditorGUILayout.Foldout(showMultiPerlin, "MultiPerlinGenProps");
        if (showMultiPerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Height Based On Multiple Perlin Noise", EditorStyles.boldLabel);
            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, serializedObject.FindProperty("perlinParameters"));

            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Gen Multi Perlin Heights"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "VoronoiGenProps");
        if (showVoronoi)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Height Based On Voronoi Noise", EditorStyles.boldLabel);

            EditorGUILayout.IntSlider(voronoiPeaks, 1, 10, new GUIContent("Peaks"));
            EditorGUILayout.Slider(voronoiMinHeight, 0.0f, 1.0f, new GUIContent("Min Height"));
            EditorGUILayout.Slider(voronoiMaxHeight, 0.0f, 1.0f, new GUIContent("Max Height"));
            EditorGUILayout.Slider(voronoiFallOff, 0.0f, 10.0f, new GUIContent("Fall Off"));
            EditorGUILayout.Slider(voronoiDropOff, 0.0f, 10.0f, new GUIContent("Drop Off"));
            EditorGUILayout.PropertyField(voronoiType);
            if (GUILayout.Button("Gen Voronoi Heights"))
            {
                terrain.Voronoi();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showMPD = EditorGUILayout.Foldout(showMPD, "MPDGenProps");
        if (showMPD)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Height Base On MPD ", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(MPDHeightMin);
            EditorGUILayout.PropertyField(MPDHeightMax);
            EditorGUILayout.PropertyField(MPDHeightDampenerPower);
            EditorGUILayout.PropertyField(MPDRoughness);
            if (GUILayout.Button("MPD"))
            {
                terrain.MPD();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showSplatMap = EditorGUILayout.Foldout(showSplatMap, "SplatMapProps");
        if (showSplatMap)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Texture The Terrain With Splat Map", EditorStyles.boldLabel);
            splatMapTable = GUITableLayout.DrawTable(splatMapTable, serializedObject.FindProperty("splatHeights"));

            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewSplatHeight();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply SplatMap"))
            {
                terrain.SplatMaps();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showVegetation = EditorGUILayout.Foldout(showVegetation, "VegGenProps");
        if (showVegetation)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Generate Vegetation", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(vegMaxTrees, 0, 10000, new GUIContent("Max Trees"));
            EditorGUILayout.IntSlider(vegTreeSpacing, 2, 20, new GUIContent("Tree Spacing"));
            vegetationTable = GUITableLayout.DrawTable(vegetationTable, serializedObject.FindProperty("vegetationList"));

            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewVegetation();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveVegetation();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Generate Vegetation"))
            {
                terrain.PlaceVegetation();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showDetail = EditorGUILayout.Foldout(showDetail, "DetailGenProps");
        if (showDetail)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Generate Detail", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Max Detail"));
            terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue;
            EditorGUILayout.IntSlider(detailSpacing, 2, 20, new GUIContent("Detail Spacing"));
            detailTable = GUITableLayout.DrawTable(detailTable, serializedObject.FindProperty("detailList"));

            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewDetails();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveDetails();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Generate Details"))
            {
                terrain.PlaceDetails();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showWater = EditorGUILayout.Foldout(showWater, "WaterGenProps");
        if (showWater)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Generate Water", EditorStyles.boldLabel);

            EditorGUILayout.Slider(waterHeight, 0.0f, 1.0f, new GUIContent("Water Height"));
            EditorGUILayout.PropertyField(waterGO);
            if (GUILayout.Button("Add Water"))
            {
                terrain.AddWater();
            }

            EditorGUILayout.PropertyField(shoreLineMat);
            if (GUILayout.Button("Add Shore"))
            {
                terrain.DrawShoreLine();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showErosion = EditorGUILayout.Foldout(showErosion, "ErosionProps");
        if (showErosion)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Erode Landscape", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(erosionType);
            EditorGUILayout.Slider(erosionStrength, 0.0f, 1.0f, new GUIContent("Erosion Strength"));
            EditorGUILayout.Slider(erosionAmount, 0.0f, 1.0f, new GUIContent("Erosion Amount"));
            EditorGUILayout.Slider(erosionSolubility, 0.001f, 1.0f, new GUIContent("Solubility"));
            EditorGUILayout.IntSlider(erosionDroplets, 0, 500, new GUIContent("Droplets"));
            EditorGUILayout.IntSlider(erosionsRiverSprings, 0, 20, new GUIContent("Springs Per River"));
            EditorGUILayout.IntSlider(erosionSmoothAmount, 0, 10, new GUIContent("Smooth Amount"));

            if (GUILayout.Button("Erode"))
            {
                terrain.Erode();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showClouds = EditorGUILayout.Foldout(showClouds, "CloudProps");
        if (showClouds)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Generate Clouds In The Sky", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(numClouds, new GUIContent("Number of Clouds"));
            EditorGUILayout.PropertyField(particlesPerCloud, new GUIContent("Particles Per Cloud"));
            EditorGUILayout.PropertyField(cloudScaleMin, new GUIContent("Cloud Min Size"));
            EditorGUILayout.PropertyField(cloudScaleMax, new GUIContent("Cloud max Size"));
            EditorGUILayout.PropertyField(cloudMat, true);
            EditorGUILayout.PropertyField(cloudShadowMat, true);
            EditorGUILayout.PropertyField(cloudColor, new GUIContent("Color"));
            EditorGUILayout.PropertyField(cloudLining, new GUIContent("Lining"));
            EditorGUILayout.PropertyField(cloudStartSize, new GUIContent("Cloud Particle Size"));
            EditorGUILayout.PropertyField(cloudMinSpeed, new GUIContent("Min Speed"));
            EditorGUILayout.PropertyField(cloudMaxSpeed, new GUIContent("Max Speed"));
            EditorGUILayout.PropertyField(cloudRange, new GUIContent("Dst Travelled"));

            if (GUILayout.Button("Generate Clouds"))
            {
                terrain.GenerateClouds();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showSmooth = EditorGUILayout.Foldout(showSmooth, "SmoothProps");
        if (showSmooth)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Smooth The Terrain", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(smoothAmount, 1, 10, new GUIContent("Smooth Amount"));
            if (GUILayout.Button("Smooth"))
            {
                terrain.SmoothTerrain();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        EditorGUILayout.PropertyField(resetBeforeGen);
        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        showHeightMap = EditorGUILayout.Foldout(showHeightMap, "ShowHeightMap");
        if (showHeightMap)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("View The Height Map", EditorStyles.boldLabel, GUILayout.Width(wSize / 2));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUILayout.Label(heightMapTexture, GUILayout.Width(wSize), GUILayout.Height(wSize));

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Refresh", GUILayout.Width(wSize)))
            {
                RefreshHeightMapDisplay(terrain);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }

        //Scrollbar ending code
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
    }
Example #25
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        CustomTerrain terrain = (CustomTerrain)target;

        EditorGUILayout.PropertyField(shouldReset);

        showRandom = EditorGUILayout.Foldout(showRandom, "Random");
        if (showRandom)
        {
            Render(new Context {
                Label  = "Set heights between random values",
                Fields = new List <Field> {
                    new Field {
                        Property = randomHeightRange
                    }
                },
                Buttons = new Dictionary <string, Action> {
                    { "Random heights", terrain.RandomTerrain }
                }
            });
        }

        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load heights");
        if (showLoadHeights)
        {
            Render(new Context {
                Label  = "Load heights from texture",
                Fields = new List <Field> {
                    new Field {
                        Property = heightMapImage
                    },
                    new Field {
                        Property = heightMapScale
                    }
                },
                Buttons = new Dictionary <string, Action> {
                    { "Load texture", terrain.LoadTexture }
                }
            });
        }

        showPerlin = EditorGUILayout.Foldout(showPerlin, "Perlin noise terrain generator");
        if (showPerlin)
        {
            Render(new Context {
                Label  = "Load perlin noise",
                Fields = new List <Field> {
                    new Field {
                        Property = perlinXScale, Min = 0, Max = 1, SliderType = SliderType.FLOAT
                    },
                    new Field {
                        Property = perlinYScale, Min = 0, Max = 1, SliderType = SliderType.FLOAT
                    },
                    new Field {
                        Property = perlinOffsetX, Min = 0, Max = 10000
                    },
                    new Field {
                        Property = perlinOffsetY, Min = 0, Max = 10000
                    },
                    new Field {
                        Property = perlinOctaves, Min = 1, Max = 10
                    },
                    new Field {
                        Property = perlinPersistance, Min = 0.1f, Max = 10, SliderType = SliderType.FLOAT
                    },
                    new Field {
                        Property = perlinHeightScale, Min = 0, Max = 1, SliderType = SliderType.FLOAT
                    },
                },
                Buttons = new Dictionary <string, Action> {
                    { "Generate perlin terrain", terrain.Perlin }
                }
            });
        }

        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple perlin");
        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Multiple perlin noise", EditorStyles.boldLabel);
            perlinParametersTable = GUITableLayout.DrawTable(perlinParametersTable, perlinParameters);
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply multiple perlin"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }

        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");
        if (showVoronoi)
        {
            Render(new Context {
                Label  = "Voronai noise",
                Fields = new List <Field> {
                    new Field {
                        Property = voronoiPeakCount, Min = 0, Max = 10
                    },
                    new Field {
                        Property = voronoiFalloff, Min = 0, Max = 10f, SliderType = SliderType.FLOAT
                    },
                    new Field {
                        Property = voronoiDropoff, Min = 0, Max = 10f, SliderType = SliderType.FLOAT
                    },
                    new Field {
                        Property = voronoiMaxHeight, Min = 0, Max = 1f, SliderType = SliderType.FLOAT
                    },
                    new Field {
                        Property = voronoiMinHeight, Min = 0, Max = 1f, SliderType = SliderType.FLOAT
                    },
                    new Field {
                        Property = voronoiType
                    }
                },
                Buttons = new Dictionary <string, Action> {
                    { "Generate voronoi", terrain.Voronoi }
                }
            });
        }

        RenderDivider();
        if (GUILayout.Button("Zero out terrain"))
        {
            terrain.ZeroOut();
        }
        serializedObject.ApplyModifiedProperties();
    }
Example #26
0
    Vector2 scrollPos; //keeps track of scroll bars position
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        CustomTerrain terrain = (CustomTerrain)target;

        EditorGUILayout.PropertyField(resetTerrain);

        /* //scrollbar UI code start
         * Rect r = EditorGUILayout.BeginVertical();
         * scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height));
         * EditorGUI.indentLevel++; */

        //foldout terrain for random height
        showRandom = EditorGUILayout.Foldout(showRandom, "Random");
        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set heights between random values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            //on button click
            if (GUILayout.Button("Random heights"))
            {
                terrain.RandomTerrain();
            }
        }

        //foldout terrain editor for input image
        showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Single Perlin Noise");
        if (showPerlinNoise)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Perlin noisee", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinXScale, 0, 0.1f, new GUIContent("X scale"));
            EditorGUILayout.Slider(perlinYScale, 0, 0.1f, new GUIContent("Y scale"));
            EditorGUILayout.IntSlider(perlinXOffset, 0, 10000, new GUIContent("X noise"));
            EditorGUILayout.IntSlider(perlinYOffset, 0, 10000, new GUIContent("Y noise"));
            EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(perlinPersistance, 0, 10f, new GUIContent("Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 1f, new GUIContent("Height scale"));
            EditorGUILayout.Slider(freqMultiplier, 0, 5f, new GUIContent("frequency Multiplier"));
            //on button click
            if (GUILayout.Button("Perlin"))
            {
                terrain.Perlin();
            }
        }

        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perlin Noise");
        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Multiple Perlin Noise", EditorStyles.boldLabel);
            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, perlinParameters);
            GUILayout.Space(20); //formatting space so buttons dont appear on slider
            //this makes the plus and minus button next to each other horizontally on the gui
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }

            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply Multiple Perlin"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }
        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Height Map in");
        if (showLoadHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set heights from input image", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            //on button click
            if (GUILayout.Button("Load Texture"))
            {
                terrain.LoadTexture();
            }
        }
        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");
        if (showVoronoi)
        {
            EditorGUILayout.IntSlider(voronoiPeaks, 1, 10, new GUIContent("Peak count"));
            EditorGUILayout.Slider(voronoiFallOff, 0, 10, new GUIContent("FallOff"));
            EditorGUILayout.Slider(voronoiDropOff, 0, 10, new GUIContent("Dropoff"));
            EditorGUILayout.Slider(voronoiMaxHeight, 0, 1, new GUIContent("Max Height"));
            EditorGUILayout.Slider(voronoiMinHeight, 0, 1, new GUIContent("Min Height"));
            EditorGUILayout.PropertyField(voronoiType);
            if (GUILayout.Button("Generate peaks"))
            {
                terrain.Voronoi();
            }
        }

        showMidpointDisplacement = EditorGUILayout.Foldout(showMidpointDisplacement, "Midpoint Displacement");
        if (showMidpointDisplacement)
        {
            if (GUILayout.Button("MP displacement"))
            {
                terrain.MidpointDisplacement();
            }
        }
        showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth");
        if (showSmooth)
        {
            EditorGUILayout.IntSlider(smoothAmount, 1, 10, new GUIContent("Smooth iterations"));
            if (GUILayout.Button("Smooth"))
            {
                terrain.Smooth();
            }
        }

        showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps");
        if (showSplatMaps)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Splat Maps", EditorStyles.boldLabel);
            splatMapTable = GUITableLayout.DrawTable(splatMapTable, serializedObject.FindProperty("splatHeights"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddSplatHeight();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply Splatmaps"))
            {
                terrain.SplatMaps();
            }
        }
        showTrees = EditorGUILayout.Foldout(showTrees, "show Trees");
        if (showTrees)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("show Trees", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxTrees, 0, 10000, new GUIContent("Max Trees"));
            EditorGUILayout.IntSlider(treeSpacing, 2, 20, new GUIContent("Tree Spacing"));
            vegetation = GUITableLayout.DrawTable(vegetation, serializedObject.FindProperty("vegetation"));
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddVegetation();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveVegetation();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply trees"))
            {
                terrain.PlantVegetation();
            }
        }

        showDetail = EditorGUILayout.Foldout(showDetail, "Detail");
        if (showDetail)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Detail", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Maximum Details"));
            EditorGUILayout.IntSlider(detailSpacing, 1, 20, new GUIContent("Detail Spacing"));
            //this line is broken even copy and pasted,,
            detailMapTable = GUITableLayout.DrawTable(detailMapTable,
                                                      serializedObject.FindProperty("details"));
            //sets the view distance of the details to the amount of objects so you can see all of them
            terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue;

            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddDetail();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveDetail();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Details"))
            {
                terrain.SpawnDetails();
            }
        }
        showErosion = EditorGUILayout.Foldout(showErosion, "Erosion");
        if (showErosion)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Erosion", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(erosionType);
            EditorGUILayout.IntSlider(erosionSmoothAmount, 0, 10, new GUIContent("Smooth AMount"));
            EditorGUILayout.Slider(erosionStrength, 0.01f, 1, new GUIContent("Erosion strength"));
            EditorGUILayout.IntSlider(springsPerDroplet, 0, 60, new GUIContent("Spring/droplet"));
            EditorGUILayout.Slider(solubility, 0, 1, new GUIContent("Solubility"));
            EditorGUILayout.IntSlider(droplets, 1, 10000, new GUIContent("Droplets"));
            EditorGUILayout.Slider(thermalStrength, 0, 1, new GUIContent("ThermalStrength"));


            if (GUILayout.Button("Erode"))
            {
                terrain.Erode();
            }
        }
        //reset button seperate
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }

        /*//scrollbar code END
         * EditorGUILayout.EndScrollView();
         * EditorGUILayout.EndVertical();
         */
        serializedObject.ApplyModifiedProperties();
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        CustomTerrain terrain = (CustomTerrain)target;

        //ScrollBar Starting code
        Rect r = EditorGUILayout.BeginVertical();

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height));
        EditorGUI.indentLevel++;


        EditorGUILayout.PropertyField(resetTerrain);

        showRandom = EditorGUILayout.Foldout(showRandom, "Random");

        //Items included in the foldout show Random
        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);                    // Creates Break between items
            GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel); // Text label
            EditorGUILayout.PropertyField(randomHeightRange);                             //SerializedProperty to be edited

            if (GUILayout.Button("Random Heights"))                                       //Generates Button
            {
                terrain.RandomTerrain();                                                  //If button pressed will execute code
            }
        }

        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights");

        // Items included in the foldout for setting terrain from image.
        if (showLoadHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            if (GUILayout.Button("Load Texture"))
            {
                terrain.LoadTexture();
            }
        }

        showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Single Perlin Noise");

        // Items included in the foldout for generating terrain from 2D Perlin noise
        if (showPerlinNoise)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("PerlinNoise", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinXScale, 0, 1, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinYScale, 0, 1, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("Offset X"));
            EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("Offset Y"));
            EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(perlinPersistance, 1, 10, new GUIContent("Persistence"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale"));
            if (GUILayout.Button("Perlin"))
            {
                terrain.Perlin();
            }
        }

        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perlin Noise");

        // Items included in the foldout for generating terrain with multiple Perlin noises;
        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Multiple Perlin Noise", EditorStyles.boldLabel);
            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, perlinParameters);  // creates a table which stores each perlin noise

            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Multiple Perlin"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }

        showVoroni = EditorGUILayout.Foldout(showVoroni, "Voronoi");

        // Items included in the foldout for generating a Voronoi mountain on the terrain
        if (showVoroni)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Voronoi", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(voronoiPeakCount, 1, 10, new GUIContent("Peak Count"));
            EditorGUILayout.Slider(voronoiFallOff, 0, 10, new GUIContent("Fall off"));
            EditorGUILayout.Slider(voronoiDropOff, 0, 10, new GUIContent("Drop off"));
            EditorGUILayout.Slider(voronoiMinHeight, 0, 1, new GUIContent("Min Height"));
            EditorGUILayout.Slider(voronoiMaxHeight, 0, 1, new GUIContent("Max Height"));
            EditorGUILayout.PropertyField(voronoiType);

            if (GUILayout.Button("Voronoi"))
            {
                terrain.Voronoi();
            }
        }

        showMidPointDisplacement = EditorGUILayout.Foldout(showMidPointDisplacement, "Mid Point Displacement");

        // Items included in the foldout for generating a Mid point displacement mountain on the terrain
        if (showMidPointDisplacement)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("MidPoint Displacement", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(MPHeightMin);
            EditorGUILayout.PropertyField(MPHeightMax);
            EditorGUILayout.PropertyField(MPHeightDampenerPower);
            EditorGUILayout.PropertyField(MPRoughness);

            if (GUILayout.Button("Mid Point Displacement"))
            {
                terrain.MidPointDisplacement();
            }
        }

        showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth Terrain");

        // Items included in the foldout for generating Smoother terrain
        if (showSmooth)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Smooth Terrain", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(SmoothAmount, 1, 10, new GUIContent("Smooth Amount"));
            if (GUILayout.Button("Smooth"))
            {
                terrain.Smooth();
            }
        }


        showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps");

        // Items included in the foldout for generating SplatMap Textures for terrain
        if (showSplatMaps)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Splat Map", EditorStyles.boldLabel);

            splatMapTable = GUITableLayout.DrawTable(splatMapTable, splatHeights);

            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewSplatHeight();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply SplatMaps"))
            {
                terrain.SplatMaps();
            }
        }


        showHeights = EditorGUILayout.Foldout(showHeights, "Height Map");

        //Items included in the foldout for generating a height map of the current terrain.
        if (showHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Current Height Map", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            int hmtSize = (int)(EditorGUIUtility.currentViewWidth - 100);
            GUILayout.Label(hmTexture, GUILayout.Width(hmtSize), GUILayout.Height(hmtSize));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Refresh", GUILayout.Width(hmtSize)))
            {
                float[,] heightMap = terrain.terrainData.GetHeights(0, 0, terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight);

                for (int y = 0; y < terrain.terrainData.heightmapHeight; y++)
                {
                    for (int x = 0; x < terrain.terrainData.heightmapWidth; x++)
                    {
                        hmTexture.SetPixel(x, y, new Color(heightMap[x, y], heightMap[x, y], heightMap[x, y], 1));
                    }
                }
                hmTexture.Apply();
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }

        showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation");

        //Items included in the foldout for generating the tree vegetation on the terrain
        if (showVegetation)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Vegetation", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxTrees, 0, 10000, new GUIContent("Maximum Trees"));
            EditorGUILayout.IntSlider(treeSpacing, 2, 20, new GUIContent("Tree Spacing"));
            vegetationTable = GUITableLayout.DrawTable(vegetationTable, vegatation);

            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("+"))
            {
                terrain.AddNewVegetation();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveVegetation();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Vegetation"))
            {
                terrain.plantVegetation();
            }
        }

        showDetail = EditorGUILayout.Foldout(showDetail, "Detail");
        //Items included in the foldout for generating the details (e.g. grass) on the terrain

        if (showDetail)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Detail", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Max Details"));
            EditorGUILayout.IntSlider(detailSpacing, 2, 20, new GUIContent("Detail Spacing"));
            DetailTable = GUITableLayout.DrawTable(DetailTable, details);

            terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue;
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("+"))
            {
                terrain.AddNewDetails();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveDetails();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Vegetation"))
            {
                terrain.AddDetails();
            }
        }

        //Items included in the foldout for generating Water onto the map.
        showWater = EditorGUILayout.Foldout(showWater, "Water");

        if (showWater)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Water", EditorStyles.boldLabel);
            EditorGUILayout.Slider(waterHeight, 0, 1, new GUIContent("Water Height"));
            EditorGUILayout.PropertyField(waterGO);

            if (GUILayout.Button("Add Water"))
            {
                terrain.Addwater();
            }

            EditorGUILayout.PropertyField(shoreMaterial);
            if (GUILayout.Button("Add ShoreLine"))
            {
                terrain.DrawShoreLine();
            }
        }

        //Items included in the foldout for enabling different types of erosion to occur on the terrain.
        showEroision = EditorGUILayout.Foldout(showEroision, "Erosion");

        if (showEroision)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Erosion", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(ErosionType);
            EditorGUILayout.Slider(ErosionStrength, 0, 1, new GUIContent("Erosion Strength"));
            EditorGUILayout.Slider(erosionAmount, 0, 1, new GUIContent("Erosion Amount"));
            EditorGUILayout.IntSlider(Droplets, 0, 500, new GUIContent("Droplets"));
            EditorGUILayout.Slider(Solubility, 0.001f, 1, new GUIContent("Solubility"));
            EditorGUILayout.IntSlider(SpringsPerRiver, 0, 20, new GUIContent("Springs Per River"));
            EditorGUILayout.IntSlider(erosionSmoothAmount, 0, 10, new GUIContent("Smooth Amount"));

            if (GUILayout.Button("Erode"))
            {
                terrain.Erode();
            }
        }


        //Items included in the foldout for generating clouds in the scene
        showClouds = EditorGUILayout.Foldout(showClouds, "Clouds");

        if (showClouds)
        {
            EditorGUILayout.PropertyField(NumberOfClouds, new GUIContent("Number of Clouds"));
            EditorGUILayout.PropertyField(ParticlePerCloud, new GUIContent("Particles Per Cloud"));
            EditorGUILayout.PropertyField(CloudStartSize, new GUIContent("Cloud Particle Size"));
            EditorGUILayout.PropertyField(CloudSize, new GUIContent("Min Size"));
            EditorGUILayout.PropertyField(CloudMaxSize, new GUIContent("Max Size"));
            EditorGUILayout.PropertyField(CloudMaterial, true);
            EditorGUILayout.PropertyField(CloudShadowMaterial, true);
            EditorGUILayout.PropertyField(CloudColor, new GUIContent("Color"));
            EditorGUILayout.PropertyField(CloudLining, new GUIContent("Lining"));
            EditorGUILayout.PropertyField(MinSpeed, new GUIContent("Min Speed"));
            EditorGUILayout.PropertyField(MaxSpeed, new GUIContent("Max Speed"));
            EditorGUILayout.PropertyField(DistanceTravelled, new GUIContent("Distance Traveled"));

            if (GUILayout.Button("Generate Clouds"))
            {
                terrain.GenerateClouds();
            }
        }

        // Creates the reset button
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }


        //Scrollbar ending code
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        CustomTerrain terrain = (CustomTerrain)target;
        Rect          r       = EditorGUILayout.BeginVertical();

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height));
        EditorGUI.indentLevel++;
        EditorGUILayout.PropertyField(resetTerrain);

        showRandom = EditorGUILayout.Foldout(showRandom, "Random");
        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            if (GUILayout.Button("RandomHeights"))
            {
                terrain.RandomTerrain();
            }
        }
        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights");
        if (showLoadHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            if (GUILayout.Button("Load Texture"))
            {
                terrain.LoadTexture();
            }
        }
        showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Perlin Noise");
        if (showPerlinNoise)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Perlin Noise", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinXScale, 0, 1, new GUIContent("perlinXScale"));
            EditorGUILayout.Slider(perlinYScale, 0, 1, new GUIContent("perlinYScale"));
            EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("perlinOffsetY"));
            EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("perlinOffsetY"));
            EditorGUILayout.IntSlider(perlinOctaves, 0, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(perlinPersistance, 0.1f, 10, new GUIContent("Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale"));
            if (GUILayout.Button("Perlin"))
            {
                terrain.Perlin();
            }
        }
        showMultiplePerlins = EditorGUILayout.Foldout(showMultiplePerlins, "Mulitple Perlin Noise");
        if (showMultiplePerlins)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Mulitple Perlin Niose", EditorStyles.boldLabel);
            perlinParametersTable = GUITableLayout.DrawTable(perlinParametersTable, perlinParameters);
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Mutiple Perlin"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }
        showWater = EditorGUILayout.Foldout(showWater, "showWater");
        if (showWater)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Water", EditorStyles.boldLabel);
            EditorGUILayout.Slider(WaterHeight, 0, 1, new GUIContent("Water Height"));
            EditorGUILayout.PropertyField(waterGo);
            if (GUILayout.Button("Add Water"))

            {
                terrain.AddWater();
            }
            GUILayout.Label("Shore Line Material", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(ShoreFoam);
            if (GUILayout.Button("Add Shoreline"))
            {
                terrain.AddShoreline();
            }
        }
        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");
        if (showVoronoi)
        {
            EditorGUILayout.IntSlider(voronoipeakCount, 1, 10, new GUIContent("Peak Count"));
            EditorGUILayout.Slider(voronoifallOff, 0, 10, new GUIContent("fall Off"));
            EditorGUILayout.Slider(voronoidropOff, 0, 10, new GUIContent("drop Off"));
            EditorGUILayout.Slider(voronoimaxHeight, 0, 1, new GUIContent("max Height"));
            EditorGUILayout.Slider(voronoimaxWidth, 0, 1, new GUIContent("max Width"));
            EditorGUILayout.PropertyField(voronoiType);
            if (GUILayout.Button("Voronoi"))
            {
                terrain.Voronoi();
            }
        }
        midPointShow = EditorGUILayout.Foldout(midPointShow, "Midpoint Displacemnet");
        if (midPointShow)
        {
            EditorGUILayout.PropertyField(midPointHeightMin);
            EditorGUILayout.PropertyField(midPointHeightMax);
            EditorGUILayout.PropertyField(midPointRoughness);
            EditorGUILayout.PropertyField(midPointDampener);
            if (GUILayout.Button("MPD"))
            {
                terrain.MidPointDisplacement();
            }
        }
        showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth");
        if (showSmooth)
        {
            EditorGUILayout.IntSlider(smoothCount, 0, 10, new GUIContent("Smooth Count"));
            if (GUILayout.Button("Smooth"))
            {
                terrain.Smooth();
            }
        }
        showSplatMap = EditorGUILayout.Foldout(showSplatMap, "Splat Map");
        if (showSplatMap)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Splat Map", EditorStyles.boldLabel);
            GUILayout.Label("Max Height Of Terrain", EditorStyles.boldLabel);
            EditorGUILayout.FloatField(HeightestPiontInTerrian);
            EditorGUILayout.FloatField(LowestPointInTerrain);
            EditorGUILayout.Slider(splatOffset, 0, .1f, new GUIContent("Offset"));
            EditorGUILayout.Slider(splatNoiseXscale, 0.001f, 1, new GUIContent("Noise X scale"));
            EditorGUILayout.Slider(splatNoiseYscale, 0.001f, 1, new GUIContent("Noise Y scale"));
            EditorGUILayout.Slider(splatNoisescaler, 0, 1, new GUIContent("Noise scaler"));
            splatMapTable = GUITableLayout.DrawTable(splatMapTable, serializedObject.FindProperty("splatHeights"));
            //splatMapTable = GUITableLayout.DrawTable(splatMapTable, splatHeights);
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewSplatHeights();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Splatmaps"))
            {
                terrain.SplatMaps();
            }
        }
        showDetail = EditorGUILayout.Foldout(showDetail, "Detail");
        if (showDetail)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Detail", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Maximum Details"));
            EditorGUILayout.IntSlider(detailsSpacing, 1, 20, new GUIContent("Detail Spacing"));
            detailMapTable = GUITableLayout.DrawTable(detailMapTable, serializedObject.FindProperty("details"));
            terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue;
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewDetails();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveDetails();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Details"))
            {
                terrain.AddDetails();
            }
        }
        showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation");
        if (showVegetation)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Vegetation", EditorStyles.boldLabel);
            EditorGUILayout.IntSlider(maxTrees, 0, 10000, new GUIContent("maximum Trees"));
            EditorGUILayout.IntSlider(treeSpacing, 2, 20, new GUIContent("Trees Spacing"));
            vegetationTable = GUITableLayout.DrawTable(vegetationTable, serializedObject.FindProperty("vegetation"));
            //splatMapTable = GUITableLayout.DrawTable(splatMapTable, splatHeights);
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewVegetation();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveVegetations();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Vegetations"))
            {
                terrain.Vegetation();
            }
        }
        showHeights = EditorGUILayout.Foldout(showHeights, "Height Map");
        if (showHeights)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            int hmtSize = (int)(EditorGUIUtility.currentViewWidth - 100);
            GUILayout.Label(hmTexture, GUILayout.Width(hmtSize), GUILayout.Height(hmtSize));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Refresh", GUILayout.Width(hmtSize)))
            {
                float[,] heightMap = terrain.terrainData.GetHeights(0, 0, terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight);
                for (int y = 0; y < terrain.terrainData.heightmapHeight; y++)
                {
                    for (int x = 0; x < terrain.terrainData.heightmapWidth; x++)
                    {
                        hmTexture.SetPixel(x, y, new Color(heightMap[x, y],
                                                           heightMap[x, y],
                                                           heightMap[x, y], 1));
                        if (heightMap[x, y] > HeightestPiontInTerrian)
                        {
                            HeightestPiontInTerrian = heightMap[x, y];
                        }
                        if (heightMap[x, y] < LowestPointInTerrain)
                        {
                            LowestPointInTerrain = heightMap[x, y];
                        }
                    }
                }
                hmTexture.Apply();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        if (GUILayout.Button("Reset"))
        {
            terrain.ResetTerrain();
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
        serializedObject.ApplyModifiedProperties();
    }
Example #29
0
    // Display loop for the inspector gui
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        CustomTerrain terrain = (CustomTerrain)target; // `target` is linked to [1] "a link to class"
        // terrain.randomHeightRange = .. is possible, but we use serialization because otherwise editing
        // the code would reset the state and we're loosing whatever we setup in the inspect

        int height = terrain.terrainData.heightmapHeight;
        int width  = terrain.terrainData.heightmapWidth;

        Rect r = EditorGUILayout.BeginVertical();

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height));
        EditorGUI.indentLevel++;

        EditorGUILayout.PropertyField(resetTerrain);
        showRandom = EditorGUILayout.Foldout(showRandom, "Random"); // show foldout toggle
        if (showRandom)
        {
            GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            if (GUILayout.Button("Random Heights"))
            {
                terrain.RandomTerrain();
            }
        }
        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights");
        if (showLoadHeights)
        {
            GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);
            if (GUILayout.Button("Load Texture"))
            {
                terrain.LoadTexture();
            }
        }
        showPerlin = EditorGUILayout.Foldout(showPerlin, "Single Perlin Noise"); // show foldout toggle
        if (showPerlin)
        {
            EditorGUILayout.Slider(perlinXScale, 0, 0.1f, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinYScale, 0, 0.1f, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinXOffset, 0, 10000, new GUIContent("Offset X"));
            EditorGUILayout.IntSlider(perlinYOffset, 0, 10000, new GUIContent("Offset Y"));
            EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(perlinPersistance, 0.1f, 10, new GUIContent("Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale"));

            if (GUILayout.Button("Generate"))
            {
                terrain.Perlin();
            }
        }
        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multple Perlin Noise"); // show foldout toggle
        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable,
                                                            serializedObject.FindProperty("perlinParameters")); // why not the class attribute we mapped?
            GUILayout.Space(40);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Multiple Perlin"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }
        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");
        if (showVoronoi)
        {
            EditorGUILayout.IntSlider(voronoiPeaks, 1, 10, new GUIContent("Peak Count"));
            EditorGUILayout.Slider(voronoiFallOff, 0, 10, new GUIContent("Falloff"));
            EditorGUILayout.Slider(voronoiDropOff, 0, 10, new GUIContent("Dropoff"));
            EditorGUILayout.Slider(voronoiMinHeight, 0, 1, new GUIContent("Min Height"));
            EditorGUILayout.Slider(voronoiMaxHeight, 0, 1, new GUIContent("Max Height"));
            EditorGUILayout.PropertyField(voronoiType);

            if (GUILayout.Button("Voronoi"))
            {
                terrain.Voronoi();
            }
        }
        showMPD = EditorGUILayout.Foldout(showMPD, "Midpoint Displacement");
        if (showMPD)
        {
            EditorGUILayout.PropertyField(mpdMinHeight);
            EditorGUILayout.PropertyField(mpdMaxHeight);
            EditorGUILayout.PropertyField(mpdDampenerPower);
            EditorGUILayout.PropertyField(mpdRoughness);

            if (GUILayout.Button("MPD"))
            {
                terrain.MidPointDisplacement();
            }
        }
        showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps");
        if (showSplatMaps)
        {
            /*
             * EditorGUILayout.Slider(splatOffset, 0, 0.1f, new GUIContent("Offset"));
             * EditorGUILayout.Slider(splatScaleX, 0.001f, 1, new GUIContent("Noise X Scale"));
             * EditorGUILayout.Slider(splatScaleY, 0.001f, 1, new GUIContent("Noise Y Scale"));
             * EditorGUILayout.Slider(splatScale, 0, 1, new GUIContent("Noise Scaler"));*/

            splatMapTable = GUITableLayout.DrawTable(splatMapTable,
                                                     serializedObject.FindProperty("splatHeights")); // why not the class attribute we mapped?
            GUILayout.Space(40);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewSplatHeight();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveSplatHeight();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply SplatMaps"))
            {
                terrain.SplatMaps();
            }
        }
        showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation");
        if (showVegetation)
        {
            EditorGUILayout.IntSlider(vegTreesMax, 1, 10000, new GUIContent("Maxium Trees"));
            EditorGUILayout.IntSlider(vegTreesSpacing, 1, 20, new GUIContent("Trees Spacing"));

            vegetationTable = GUITableLayout.DrawTable(vegetationTable,
                                                       serializedObject.FindProperty("vegetation")); // why not the class attribute we mapped?
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                terrain.AddNewVegetation();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemoveVegetation();
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Apply Vegetation"))
            {
                terrain.ApplyVegetation();
            }
        }
        showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth");
        if (showSmooth)
        {
            EditorGUILayout.IntSlider(smoothAmount, 1, 10, new GUIContent("Smooth amount"));
            if (GUILayout.Button("Smooth"))
            {
                terrain.SmoothN();
            }
        }

        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }
        showHeightMap = EditorGUILayout.Foldout(showHeightMap, "HeightMap");
        if (showHeightMap)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(hmTexture, GUILayout.Width(height), GUILayout.Height(width));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Refresh"))
            {
                Color color;
                float cv;
                hmTexture          = new Texture2D(width, height, TextureFormat.ARGB32, false);
                float[,] heightMap = terrain.terrainData.GetHeights(0, 0, width, height);

                // why alphamap?
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        cv    = heightMap[x, y];
                        color = new Color(cv, cv, cv, 1);
                        hmTexture.SetPixel(x, y, color);
                    }
                }
                hmTexture.Apply();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }


        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
        serializedObject.ApplyModifiedProperties();
    }
Example #30
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        CustomTerrain terrain = (CustomTerrain)target;

        EditorGUILayout.PropertyField(resetTerrain);

        showRandom = EditorGUILayout.Foldout(showRandom, "Random");

        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeightRange);
            if (GUILayout.Button("Random Heights"))
            {
                terrain.RandomTerrain();
            }
        }

        showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights");

        if (showLoadHeights)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights From Texture", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(heightMapImage);
            EditorGUILayout.PropertyField(heightMapScale);

            if (GUILayout.Button("Load Texture"))
            {
                terrain.LoadTexture();
            }
        }

        showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Single Perlin Noise");

        if (showPerlinNoise)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Perlin Noise Scale", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinXScale, 0, 0.1f, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinYScale, 0, 0.1f, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinXOffset, 0, 10000, new GUIContent("X Offset"));
            EditorGUILayout.IntSlider(perlinYOffset, 0, 10000, new GUIContent("Y Offset"));

            EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(perlinPersistance, 0.1f, 10, new GUIContent("Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale"));



            if (GUILayout.Button("Perlin Noise"))
            {
                terrain.Perlin();
            }
        }

        showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perlin Noise");
        if (showMultiplePerlin)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Multiple Perlin Noise", EditorStyles.boldLabel);

            perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, perlinParameters);
            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();


            if (GUILayout.Button("+"))
            {
                terrain.AddNewPerlin();
            }
            if (GUILayout.Button("-"))
            {
                terrain.RemovePerlin();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Apply Multiple Perlin"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }

        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");
        if (showVoronoi)
        {
            if (GUILayout.Button("Voronoi"))
            {
                terrain.Voronoi();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }

        serializedObject.ApplyModifiedProperties();
    }