I would like to create a grid of properties corresponding to the patches of the terrain. If, for example, the user creates a 3x3 terrain, then I would like to have 3x3 panels in my CustomEditor, with each containing some properties, e.g. (float)min height, (float)max height, (int) biome type. The panels would have to be wrapped up in horizontal and vertical scrollbars, but to start with I would just like to be able to create a grid of panels.
I already have a method for extracting the patch number / configuration in the terrain, the problem is just how to lay it out in the editor. I’m currently inheriting from the GenericEditor, overriding Initialize and using a base.Initialize(layout) to pull the original terrain properties back in.
I’ve experimented with LayoutElementsContainer horizontalContainer = layout.HorizontalPanel() and then adding properties to the horizontalContainer, but I can’t seem to get this to behave nicely (e.g. horizontalContainer.FloatValue gets squashed into a narrow width, which I can’t figure a way to change).
Here is a sample of my code:
using FlaxEngine;
using FlaxEditor.CustomEditors.Elements;
#if FLAX_EDITOR
using FlaxEditor.CustomEditors.Editors;
using FlaxEditor.CustomEditors;
namespace TerrainSystem
{
[CustomEditor(typeof(Terrain))]
public class TS_Editor : GenericEditor
{
public override DisplayStyle Style => DisplayStyle.Inline;
public override void Initialize(LayoutElementsContainer layout)
{
base.Initialize(layout);
Terrain terrain = (Terrain)this.Values[0];
layout.Label("Procedural Terrain", TextAlignment.Near);
layout.Space(10);
FloatValueElement minHeight = layout.FloatValue("Min Height", "Float value for the min height of the terrain.");
minHeight.Value = 100;
FloatValueElement maxHeight = layout.FloatValue("Max Height", "Float value for the max height of the terrain.");
maxHeight.Value = 500;
ButtonElement btn_HeightMap = layout.Button("Regenerate Height Map", Color.Gray);
btn_HeightMap.Button.Clicked += () => GenerateHeightMap(terrain, minHeight.Value, maxHeight.Value);
Any suggestions would be much appreciated.
Thanks.