godotengine / godot

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

Global enums not being updated in the inspector #83346

Open jsladovic opened 1 year ago

jsladovic commented 1 year ago

Godot version

v4.1.1.stable.mono.official [bd6af8e0e]

System information

Godot v4.1.1.stable.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3070 (NVIDIA; 31.0.15.3699) - Intel(R) Core(TM) i9-10850K CPU @ 3.60GHz (20 Threads)

Issue description

When I create my custom resource and have an export variable which is an enum created in another script, if I make any changes to the enum, they will not automatically reload in the inspector. In the posted example I have two enum export varibles, one enum is defined in the script itself, the other in another script (called enums.gd in this example). Whenever I add/update/remove some members from the local enum, the changes are automatically reflected in the inspector for any instance of the resource.

When I make changes to the enum defined in the external script, I don't see any changes until I refresh the main resource script.

Steps to reproduce

In the example, open the new_resource.tres so you can see the values in the inspector, go to the enums.gd script and add a new value to the enum. The value will not be displayed in the dropdown for the enum. Make changes to the test_resource.gd script, the new value will now be added to the dropdown in the inspector.

Minimal reproduction project

bug_recreate.zip

jsladovic commented 1 year ago

Just as an additional note, I have noticed quite a few times that my code in the editor wouldn't allow me to Ctrl+click on my newly added functions, like there was an older version of the code cached somewhere, but not updated.

Polatrite commented 11 months ago

I am also experiencing this issue on v4.1.stable.official 970459615, with a nearly identical setup - separate enums.gd file that is a project autoload, then modifying custom resources in the inspector.

I cannot figure out a good way to trigger a refresh, either, so I do not have a workaround besides reloading the project. If anyone finds a workaround to refresh, please let us know.

jsladovic commented 10 months ago

Just to add a bit more context, still happens after migrating to 4.2. Also, it's not only the enums, any references seem to be slow to reload. And it's a fairly small project so far, can't imagine it's down to its size.

DarkhunterStd commented 9 months ago

It's happening to me too. I don't know if it's related to the engine version, or if it has something to do with my project (cache, some error I can't see, etc.). I didn't have this issue on my last project with 4.1. Yet I got this issue from nowhere just some days ago.

suikanon commented 5 months ago

I also ran into this issue on 4.2.

Pesquisador-Stefano commented 5 months ago

I cannot figure out a good way to trigger a refresh, either, so I do not have a workaround besides reloading the project. If anyone finds a workaround to refresh, please let us know.

I don't know where i found this tip, but you can refresh the enum if you make any change(even comments) to the script that uses the enum and save it. Tested on 4.3.beta.1

mikemike37 commented 2 months ago

Issue still occurring in v4.3.stable.official and the workaround described above did not refresh the enums in the inspector for me.

UPDATE: If I move the enum into the resource for which the inspector is shown, everything updates immediately just as I want:

example_resource.gd
extends Resource
enum ExampleEnum{One, Two}
@export var thing_in_inspector: ExampleEnum

The issue seems to only occur when the enum is declared outside of the resource for which an inspector is shown.

alanenggb commented 6 days ago

Issue still occurring in v4.3.stable.official and the workaround described above did not refresh the enums in the inspector for me.

It worked for me when I changed the resource and saved. Simply saving without changing doesn't work.

Another tip, the values selected on inspector might be wrong if you add a value at the start of your enum, so double check after editing it.