Is there a way to show the properties of a custom class in the Inspector using _GetPropertyList()?

The Dictionary _get_property_list ( ) virtual example works, but not with a custom class. What could be the problem?

`using Godot;

[Tool]
public partial class Test : Node
{
public CustomInspector EgyediInspector { get; set; } = new CustomInspector();

[Tool]
public partial class CustomInspector : Node
{
public int Egesz;
public float Lebegopontos;

#if TOOLS
public override Godot.Collections.Array<Godot.Collections.Dictionary> GetPropertyList()
{
GD.Print("Start - CustomInspector.
GetPropertyList()");

    var properties = new Godot.Collections.Array<Godot.Collections.Dictionary>();
    properties.Add(new Godot.Collections.Dictionary()
    {
        { "name", "Egesz" },
        { "type", (int)Variant.Type.Int },
        { "usage", (int)PropertyUsageFlags.Default }
    });

     properties.Append(new Godot.Collections.Dictionary()
     {
         { "name", "Lebegopontos" },
         { "type", (int)Variant.Type.Float },
         { "usage", (int)PropertyUsageFlags.Default },
     });

    properties.Append(new Godot.Collections.Dictionary()
    {
        { "name", "CustomInspector/Szoveg" },
        { "type", (int)Variant.Type.String },
        { "usage", (int)PropertyUsageFlags.Default }
    });

    GD.Print("End - CustomInspector._GetPropertyList()");

    return properties;
}

#endif
}
}`

  • xyz replied to this.

    xyz By using [Export], only the class is displayed in the Inspector, the properties in the class aren't displayed.
    I read that using [Export] only the built-in simple types are displayed.

    `using Godot;

    [Tool]
    public partial class Test2 : Node
    {
    [Export] public CustomInspector EgyediInspector { get; set; } = new CustomInspector();

    [Tool]
    public partial class CustomInspector : Node
    {
        [Export] public int Egesz;
        [Export] public float Lebegopontos;
        [Export] public string Szoveg;
    }

    }`

    P.S. Does anyone know why all the source code doesn't show up in the code window??? (on the forum)

    • xyz replied to this.

      xyz yeah this, and a combination of resources.

      A custom inspector is fine for presenting data, like a grid or something but generally, [Export] the desired properties should do fine. I think here, a custom resource will work better.

      @Trufiadok preformatted code should be indented by spaces.

        Trufiadok CustomInspector needs to inherit from Resource. Then you'll be able to edit its properties in the inspector.

          xyz Unfortunately, it doesn't work.

          `using Godot;
          public partial class Test4 : Resource
          {

          [Export] public CustomInspector EgyediInspector = new CustomInspector();
           
          public partial class CustomInspector : Resource
          {
              [Export] public int Egesz;
              [Export] public float Lebegopontos;
              [Export] public string Szoveg;
          }

          }`

          xyz I apologize profusely. 🙂
          I didn't select 'EgyediInspector' from the drop down menu. It's working.

          Thank you very much!

          Works with "Advanced exports", too - Godot C# exported properties - Advanced exports

          `using Godot;

          [Tool]
          public partial class Test : Node
          {
          [Export] public CustomInspector EgyediInspector = new CustomInspector();

          [Tool]
          public partial class CustomInspector : Resource
          {

          public int Egesz;
          public float Lebegopontos;
          public string Szoveg;

          #if TOOLS

          public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetPropertyList()
          {
          
              var properties = new Godot.Collections.Array<Godot.Collections.Dictionary>();
              properties.Add(new Godot.Collections.Dictionary()
              {
                  { "name", "Egesz" },
                  { "type", (int)Variant.Type.Int },
                  { "usage", (int)PropertyUsageFlags.Default },
                  { "hint", (int)PropertyHint.None }
              });
          
              properties.Add(new Godot.Collections.Dictionary()
              {
                  { "name", "Lebegopontos" },
                  { "type", (int)Variant.Type.Float },
                  { "usage", (int)PropertyUsageFlags.Default },
                  { "hint", (int)PropertyHint.None }
              });
          
              properties.Add(new Godot.Collections.Dictionary()
              {
                  { "name", "Szoveg" },
                  { "type", (int)Variant.Type.String },
                  { "usage", (int)PropertyUsageFlags.Default }
              });
          
              return properties;
          }

          #endif
          }
          }
          `