Issue displaying properties of a ScriptableObject within a MonoBehaviour Custom Inspector

Hey everyone,

I’m currently facing a challenge while working on a custom inspector in Unity using UIToolKit. I have a MonoBehaviour called WorldGenerator, and within it, there’s a property named GenerationData, which is a ScriptableObject. My goal is to create a custom inspector using UIToolkit that displays both the properties of WorldGenerator and the properties within GenerationData.

So far, I’ve managed to display the properties of WorldGenerator in the custom inspector, but I’m struggling to figure out how to access and display the properties of GenerationData within the same inspector.

I’ve searched through the documentation and various forums, but I couldn’t find a solution that addresses this specific scenario.

This is the code:

The result:
9639983--1370600--upload_2024-2-12_19-7-15.png

Thank you in advance!

You can use an inspector element: Unity - Scripting API: InspectorElement

It will draw the inspector for the type bound to it.

That’s what I’m trying to use above, as you can see in the “InspectorElement.FillDefaultInspector” but it doesn’t work, I’m not quite grasping the ‘bind’ part of the InspectorElement :frowning:

Instance one with new, bound to the scriptable object, then add it to the visual element tree.

1 Like

It worked! thank you very much!!

1 Like