I use this code to add an additional parameter to the terrain object properties (as an example):
using FlaxEngine;
#if FLAX_EDITOR
using FlaxEditor.CustomEditors;
using FlaxEditor.CustomEditors.Editors;
using FlaxEditor.CustomEditors.Elements;
[CustomEditor(typeof(Terrain))]
public class Test_Editor : GenericEditor
{
public override DisplayStyle Style => DisplayStyle.Inline;
public override void Initialize(LayoutElementsContainer layout)
{
base.Initialize(layout);
FloatValueElement testVar = layout.FloatValue("testVar", "lost value");
testVar.Value = 2;
}
}
#endif
Create a terrain and you will see the additional property at the end of the normal terrain properties.
If I change the value of testVar in the property window and then click another game object, when I come back to the terrain the testVar value reverts to its default value. How do I keep it at the updated value?