+1 vote

I use getproperty_list() in tool mode for a lot of custom resources since groups and categories are pretty good for organizing. I always wanted to export specific Arrays via this function but I never could find a proper way, not even a hint in the documentation either...

But today I made some tests via printing the original getpropertylist() function and found a bizzarre and hidden way to do it

If you want to add an Array of Strings with MULTILINE you would do:

export (Array, String, MULTILINE) var array_test: Array

Which would convert in getpropertylist() as:

        "class_name": "", 

I figured that the hint string is saying TYPESTRING (4) / PROPERTYHINTMULTILINETEXT(18).

Basically you can do the same as the normal export if you specify it via hint_string, but only if you use the property hint 24, which is undocumented (see https://docs.godotengine.org/es/stable/classes/class_%40globalscope.html#enum-globalscope-propertyhint)

So in short my question is: Are there other hidden property list tricks? What other hints are hidden for common users?

Godot version 3.3.3
in Engine by (112 points)
edited by

2 Answers

+2 votes

I found the full PropertyHint enum in object.h if anyone is interested:

enum PropertyHint {
    PROPERTY_HINT_NONE, ///< no hint provided.
    PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional"
    PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit
    PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
    PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease) use "attenuation" hint string to revert (flip h), "full" to also include in/out. (ie: "attenuation,inout")
    PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
    PROPERTY_HINT_SPRITE_FRAME, // FIXME: Obsolete: drop whenever we can break compat. Keeping now for GDNative compat.
    PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
    PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
    PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"
    PROPERTY_HINT_DIR, ///< a directory path must be passed
    PROPERTY_HINT_GLOBAL_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"
    PROPERTY_HINT_GLOBAL_DIR, ///< a directory path must be passed
    PROPERTY_HINT_RESOURCE_TYPE, ///< a resource object type
    PROPERTY_HINT_MULTILINE_TEXT, ///< used for string properties that can contain multiple lines
    PROPERTY_HINT_PLACEHOLDER_TEXT, ///< used to set a placeholder text for string properties
    PROPERTY_HINT_COLOR_NO_ALPHA, ///< used for ignoring alpha component when editing a color
    PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose
    PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, ///< so something else can provide this (used in scripts)
    PROPERTY_HINT_METHOD_OF_VARIANT_TYPE, ///< a method of a type
    PROPERTY_HINT_METHOD_OF_BASE_TYPE, ///< a method of a base type
    PROPERTY_HINT_METHOD_OF_INSTANCE, ///< a method of an instance
    PROPERTY_HINT_METHOD_OF_SCRIPT, ///< a method of a script & base
    PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type
    PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type
    PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance
    PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base
    PROPERTY_HINT_OBJECT_TOO_BIG, ///< object is too big to send
    PROPERTY_HINT_SAVE_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,". This opens a save dialog
    // When updating PropertyHint, also sync the hardcoded list in VisualScriptEditorVariableEdit
by (112 points)
+1 vote

You can always do custom checking if you know the export type. For example:

export(Array, NodePath) var my_test := []

func _init():
    for info in get_property_list():
        if info.name == "my_test":

Would print: {class_name:, hint:24, hint_string:15:, name:test, type:19, usage:8199}, revealing a "hidden" hint type 24 for NodePathArray.

by (38 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.