+2 votes

I'm trying to create a group of vars that will be displayed in editor only if "assettype" is of a certain type (as told in this: https://godotengine.org/qa/31170/is-it-possible-to-export-expose-variables-conditionally). I don't want to use TYPEINT as the type, I want to use enum (to make the editor easier to read), but the editor don't allow this. There is any way of do this?

enum types { SKILL, ITEM, EQUIPMENT }
func _get_property_list():
var property_list = []
property_list.append({
    "hint": PROPERTY_HINT_NONE,
    "usage": PROPERTY_USAGE_DEFAULT,
    "name": "group/asset_type",
    "type": TYPE_INT #here I want something like this-> "type": types
})
in Engine by (84 points)

2 Answers

+2 votes

Can be done this way:

property_list.append({
    "hint": PROPERTY_HINT_ENUM,
    "usage": PROPERTY_USAGE_DEFAULT,
    "name": "group/asset_type",
    "type": TYPE_INT,
    "hint_string": PoolStringArray(types.keys()).join(",")
})
by (156 points)
0 votes

Godot 4 solution:

properties.append({
    "name": "hammer_type",
    "type": TYPE_STRING,
    "usage": PROPERTY_USAGE_DEFAULT, 
    "hint": PROPERTY_HINT_ENUM,
    "hint_string": ",".join(Enums.Type.keys())
})
by (70 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 [email protected] with your username.