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

Watch for edited resources in editor #18076

Open
supagu opened this issue Apr 9, 2018 · 6 comments
Open

Watch for edited resources in editor #18076

supagu opened this issue Apr 9, 2018 · 6 comments

Comments

@supagu
Copy link
Contributor

supagu commented Apr 9, 2018

So I am writing a C++ plugin for godot. The user assigns a material to my custom Spatial node. Now I want to be notified when this material is changed in the editor.

It seems the add_change_receptor API nor the CoreStringNames::get_singleton()->changed signal are emitted when say the materials albedo colour changes for example.
So my next avenue was to try to connect to the property editor "variant_changed" signal, but there seems to be no way to determine what object the Property editor is editing.

I would like some way to watch when the material is modified.

@ghost
Copy link

ghost commented Apr 9, 2018

For change_receptors to work, the Resource must call _change_notify(string) when it's changed. See TileSet for example.

_change_notify("texture");

@supagu
Copy link
Contributor Author

supagu commented Apr 9, 2018

yes, the material does not call this which i would expect when the colour is changed.

@Zylann
Copy link
Contributor

Zylann commented Apr 9, 2018

I would like materials to give me this information too when they change, especially ShaderMaterials with custom properties, because currently for design reasons I am forced to update internal materials of my plugin every frame in the editor, which is costy (I use ShaderMaterial as a container for user-defined shader constants, since my plugin abstracts a complex set of shaders).
My only alternative is to write a completely custom set of properties that is identical to what you see in ShaderMaterial, AND write an editor for them (from scratch!)

@akien-mga akien-mga added this to the 4.0 milestone Sep 4, 2020
@akien-mga
Copy link
Member

For the reference, the idea for 4.0 is to drop the change receptor API which is pretty hacky, and instead make the Inspector poll for changes constantly (which could then be notified to the EditorInterface/EditorInspector API I guess for plugin use).

14:36 <reduz> Akien: the change receptor API needs to go away
14:36 <reduz> and the inspector needs to constantly poll for changes
14:37 <reduz> this will simplify things enormously, the problem is that when I tried to do it, I found we merged plenty of PRs of contributors hacking the change receptors for other things not the inspector that will need to be rewritten in a different way and it was quite some work
14:37 <reduz> so I never got around to fix this
14:37 <reduz> it has been a problem for a long time now

@Calinou
Copy link
Member

Calinou commented Feb 28, 2022

_change_notify() was removed in master. For plugins, Object now has a property_list_changed signal which can be used for this purpose.

@Calinou Calinou closed this as completed Feb 28, 2022
@Zylann
Copy link
Contributor

Zylann commented Feb 28, 2022

@Calinou I'm not sure it relates to this issue. property_list_changed and _change_notify was for notifying the inspector that the object's properties changed.

But this issue is about the other side, where you have a reference to a resource, and want to know when it changed. The changed signal exists, but apparently is not always emitted. Alternatives exist but weren't working either in these cases. The inspector now polls for changes, but I'm not sure it is sharing this information through any API and that would only work for the inspector.

It seems the add_change_receptor API nor the CoreStringNames::get_singleton()->changed signal are emitted when say the materials albedo colour changes for example.

I would like materials to give me this information too when they change, especially ShaderMaterials with custom properties

@Calinou Calinou reopened this Feb 28, 2022
@KoBeWi KoBeWi removed this from the 4.0 milestone May 9, 2022
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

5 participants