Godot: Exported enums do not allow default value

Created on 11 Jan 2018  路  10Comments  路  Source: godotengine/godot

Godot version:

master branch, commit 554e95747, but really all versions

OS/device including version:

Arch Linux

Issue description:

As the title says, when exporting a variable with an enum type, it does not allow the value to be set.

Steps to reproduce:

Given this code:

enum Foobar { FOO, BAR }
export(Foobar) var foobar = Foobar.BAR

func _ready():
  print(foobar)

foobar is null.

bug gdscript

Most helpful comment

馃憤 ran into this as well

enum Direction {UP, DOWN, LEFT, RIGHT}
export(Direction) var facing = DOWN

Assigning my integer value as the default for now so that I get the behavior I expected in the editor

enum Direction {UP, DOWN, LEFT, RIGHT}
export(Direction) var facing = 1

All 10 comments

CC @bojidar-bg

I think the problem is within this block, but I haven't yet figured out what to change or add. If someone were to provide a bit of insight I can probably fix it myself.

No idea what might have caused it, it should work fine...
This block should just make a PropertyInfo(Variant::INT, "..", HINT_ENUM, "text:0,text:1..")

The problem lies somewhere else, because it shows the value in editor, it's just Null when running the code.

馃憤 ran into this as well

enum Direction {UP, DOWN, LEFT, RIGHT}
export(Direction) var facing = DOWN

Assigning my integer value as the default for now so that I get the behavior I expected in the editor

enum Direction {UP, DOWN, LEFT, RIGHT}
export(Direction) var facing = 1

Just hit the same. Thanks for the workaround @KennethWilke

Yup this is a sleigh one that I had the fortunate headache of running into.

Potentially fixed by #19635, but needs #19534 to be fixed before it can be tested :(.

@bojidar-bg I believe #19534 was sufficient and this can be closed. It is working for me on the latest master without #19635

Ok, closing as fixed by #19635. If it is still an issue, we might reopen it later on.

Was this page helpful?
0 / 5 - 0 ratings