0 votes

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:

props.append({
        "class_name": "", 
        "hint":24, 
        "hint_string":"4/18", 
        "name":"array_test", 
        "type":TYPE_ARRAY, 
        "usage": PROPERTY_USAGE_DEFAULT
    })

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 (100 points)
edited by

1 Answer

+1 vote

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_LAYERS_2D_RENDER,
    PROPERTY_HINT_LAYERS_2D_PHYSICS,
    PROPERTY_HINT_LAYERS_3D_RENDER,
    PROPERTY_HINT_LAYERS_3D_PHYSICS,
    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_IMAGE_COMPRESS_LOSSY,
    PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS,
    PROPERTY_HINT_OBJECT_ID,
    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_NODE_PATH_VALID_TYPES,
    PROPERTY_HINT_SAVE_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,". This opens a save dialog
    PROPERTY_HINT_MAX,
    // When updating PropertyHint, also sync the hardcoded list in VisualScriptEditorVariableEdit
};
by (100 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 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.