Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setter function is not called for newly created export variables #81972

Closed
tokengamedev opened this issue Sep 20, 2023 · 6 comments
Closed

Setter function is not called for newly created export variables #81972

tokengamedev opened this issue Sep 20, 2023 · 6 comments

Comments

@tokengamedev
Copy link

Godot version

4.2.dev.5

System information

Windows 11

Issue description

When you create an export variable with setter function, then changing the value in the inspector, does not call the setter function.

Steps to reproduce

Create a scene
Add an export variable as below:

enum SIZE {SMALL= 100, NORMAL = 200, LARGE = 400}

@export var image_size : SIZE = SIZE.NORMAL:
	set(value):
		print(value)
@export var image_length: int = 0:
	set(value):
		print(value)

no go back to the inspector and change the values. There will be no print statements as the methods are not called.

Workaround:
Restart the editor and it will work

Minimal reproduction project

If required, I can provide one, but loading the project, will not reproduce the bug.

@tokengamedev tokengamedev changed the title GDScript: Setter function is not called for newly created export variables Setter function is not called for newly created export variables Sep 20, 2023
@tokengamedev
Copy link
Author

may be adding the @tool required editor restart. it is hard to figure out, which one is the issue.

@mieldepoche
Copy link
Contributor

this works on my end:

@tool
extends Node

enum SIZE {SMALL= 100, NORMAL = 200, LARGE = 400}

@export var image_size : SIZE = SIZE.NORMAL:
    set(value):
        print(value)
@export var image_length: int = 0:
    set(value):
        print(value)

you just need to reload your scene (Scene > Reload Saved Scene) for your new tool script to start acting I think

@tokengamedev
Copy link
Author

I will test this in 3.x and 4.1 and update

@tokengamedev
Copy link
Author

Tested on 3.5.2
The behavior was instantaneous and worked fine. It didn't require reload of scene or Project
Tested on 4.1.1
The behavior was similar to the issue here. It required either Reload of Saved scene or Project

It still remains a regression bug.

you just need to reload your scene (Scene > Reload Saved Scene) for your new tool script to start acting I think

This is not the solution, in my opinion. and appreciate testing the scenario.

@Reverendissimo
Copy link

same issue here. saving and reloading does not change anything.
i can see in the output that something is called but not my function.
the value in the inspector revert to default if i try to change it
image
image

@dalexeev
Copy link
Member

Thanks for reporting the bug nonetheless!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants