+1 vote

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 (79 points)

1 Answer

+1 vote

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 (154 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.