Hi, I am trying to create a pure C# class to create a noise texture or heightmap. To make my life easier, I would like to be able to preview the noise as I adjust it.
Here is the class:
public class NoiseSettings
{
[SerializeField] TransformNoise transformNoise = TransformNoise.Default;
[SerializeField] FractalNoise fractalNoise = FractalNoise.Default;
public const int previewImageSize = 256;
Texture2D texture;
#region Getters & Setters
public Texture2D Texture => texture;
public FractalNoise Settings => fractalNoise;
public TransformNoise Transform => transformNoise;
#endregion
void OnValidate()
{
CreateTexture();
}
public Texture2D CreateTexture()
{
if (texture == null) texture = new Texture2D(previewImageSize, previewImageSize);
CSNoise noise = new CSNoise();
texture = noise.GetTexture(texture, fractalNoise, transformNoise);
return texture;
}
}
So I want to keep the default inspector and add a VisualElement to display the texture.
The PropertyField is what automatically draws a SerializedProperty: Unity - Scripting API: PropertyField
Just add a visual element for the property field, alongside one to preview the texture.
I must do something wrong because the UI doesn’t show up:
I have the following message: “No GUI Implemented”
[CustomPropertyDrawer(typeof(NoiseSettings))]
public class NoisePreviewEditor : PropertyDrawer
{
bool isPressing;
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
VisualElement root = new VisualElement();
root.Add(new Label("NOISE"));
PropertyField propertyField = new PropertyField(property);
root.Add(propertyField);
return root;
}
}
Probably means whatever this type is being drawn is is being drawn with IMGUI. Make sure it doesn’t have an IMGUI custom inspector.
You can easily confirm this with the UI Toolkit Debugger.
Also check that this option in Project Settings → Editor is off:

I renamed the class with a very complex name to be sure that nothing have the same name even in another namespace but it did not solve the issue.
Here is what I get when I inspect with the debugger tool:


It was unchecked
Not sure what’s going wrong then.
This simple example works fine for me:
[CreateAssetMenu(menuName = "LBG/Testing/Test Scriptable Object")]
public class TestScriptableObject : ScriptableObject
{
public SomeClass SomeClass;
}
[System.Serializable]
public class SomeClass
{
public int SomeInt;
public string SomeString;
}
[CustomPropertyDrawer(typeof(SomeClass))]
public class SomeClassPropertyDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var root = new VisualElement();
var label = new Label("Some Class");
root.Add(label);
var propertyField = new PropertyField(property);
propertyField.Bind(property.serializedObject);
root.Add(propertyField);
return root;
}
}
Do you have any custom inspector plugins? Odin Inspector, or any of the more basic ones?