Godot Version
v4.8.dev2.mono.official
Question
I’m trying to export some custom properties in C# using _get_property_list(), works well for basic types like float or int, but how do I create a property that is just “Variant”, letting you choose a type in the editor (like when you export a variant array)? Or a “Resource” property?
The usage flag “Property_Usage_Nil_is_Variant” would suggest this is possible by setting type to Variant.Type.Nil, and returning “default” as its default value, but this doesn’t work.
There’s no separate Variant.Type for “any Variant” or “Resource”. You fake them with type + usage/hint, and you must back them with _Get / _Set (the property list alone doesn’t store anything). Also a “default” entry in the dict isn’t how defaults work here.
Untyped Variant (type picker in the inspector):
private Variant _myVariant;
public override Array<Dictionary> _GetPropertyList()
{
return
[
new Dictionary
{
{ "name", "my_variant" },
{ "type", (int)Variant.Type.Nil },
{ "usage", (int)(PropertyUsageFlags.Default | PropertyUsageFlags.NilIsVariant) },
},
];
}
public override Variant _Get(StringName property)
{
if (property == "my_variant")
return _myVariant;
return default;
}
public override bool _Set(StringName property, Variant value)
{
if (property == "my_variant")
{
_myVariant = value;
return true;
}
return false;
}
Nil alone isn’t enough; you need PropertyUsageFlags.NilIsVariant with Default.
Resource:
new Dictionary
{
{ "name", "my_resource" },
{ "type", (int)Variant.Type.Object },
{ "hint", (int)PropertyHint.ResourceType },
{ "hint_string", "Resource" }, // or "Texture2D", your [GlobalClass] name, etc.
{ "usage", (int)PropertyUsageFlags.Default },
}
Store it as Resource (or a more specific type) in _Get / _Set. For custom resource scripts, [GlobalClass] (and often [Tool] if the host is a tool script) matters.
If it still shows blank, can you paste your full _GetPropertyList + _Get / _Set?
facedesks
I did exactly that but I used "usage_flags" instead of "usage".
Because the only documentation I found used PropertyInfo(type, name, hint, hint_string, usage_flags)
Thank you very much 
Yep, PropertyInfo(..., usage_flags) is the ctor param name. In the dictionary from _GetPropertyList the key is still "usage". Easy to mix up.