godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.93k stars 21.15k forks source link

[3.x] Export doesn't work using enums from another class #61157

Open afk-mario opened 2 years ago

afk-mario commented 2 years ago

Godot version

v3.4.4.stable.arch_linux

System information

Arch Linux x86_64 5.15.37-1-lts

Issue description

When trying to use the enum TransitionType from the Tween like this:

export (Tween.TransitionType) var transition_type := Tween.TRANS_CUBIC

I get the following error:

invalid index 'TransitionType' in constant expression

For now I'm defining the enum on the script itself to get the dropdown in the editor but is not ideal

enum TRANSITION_TYPES {
    TRANS_LINEAR,
    TRANS_SINE,
    TRANS_QUINT,
    TRANS_QUART,
    TRANS_QUAD,
    TRANS_EXPO,
    TRANS_ELASTIC,
    TRANS_CUBIC,
    TRANS_CIRC,
    TRANS_BOUNCE,
    TRANS_BACK
}

enum EASE_TYPES {
    EASE_IN,
    EASE_OUT,
    EASE_IN_OUT,
    EASE_OUT_IN
}

export (float, 0, 2) var tween_duration := 0.5
export (EASE_TYPES) var ease_type := 1
export (TRANSITION_TYPES) var transition_type := 3

Related bug https://github.com/godotengine/godot/issues/19704

Steps to reproduce

Create a new gdscript and export a variable using a enum from the Tween class

Minimal reproduction project

export-from-tween-class.zip

Tummyache commented 2 years ago

I'm running into this issue with an enum from one of my autoload scripts. The strange thing was that it was working perfectly for months and just stopped today. The last thing that I did before it stopped working was add a node to a completely different autoload scene.