Skip to content

Add support for enum script component properties #10912

@paweljarosz

Description

@paweljarosz

Is your feature request related to a problem? Please describe (REQUIRED):
Inconvenience of usage of script component properties with e.g. hashes, than can have typos.

Image

Describe the solution you'd like (REQUIRED):
Allow to use a table of hashes in go property API to define a "enum" of available values (hashes or integers?) to choose from.

go.property("card_types", { hash("special_card_1"), hash("special_card_2"), hash("normal_card_1") })
go.property("spawn_amount", { 2, 5, 10 })

Then in Properties Pane in Editor - those can be selected from a drop-down menu (similarly like e.g. some GUI properties:)

Image

Describe alternatives you've considered (REQUIRED):
Group several other existing properties into a "group" ?

go.property("type_1", 1)
go.property("type_2", 2)
...
go.group_properties({"type_1", "type_2", ... })

Additional context (OPTIONAL):
https://forum.defold.com/t/enum-script-properties/12620

Similar:
#10655

Metadata

Metadata

Assignees

No one assigned

    Labels

    bobIssues related to the bob command line build tooleditorIssues related to the Defold editorengineIssues related to the Defold enginefeature requestA suggestion for a new featurego_property

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions