-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
.NET: Add a warning in the inspector when properties might be out of sync #85869
.NET: Add a warning in the inspector when properties might be out of sync #85869
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for working on this.
modules/mono/editor/GodotTools/GodotTools/Inspector/InspectorPlugin.cs
Outdated
Show resolved
Hide resolved
74176e6
to
39e1fec
Compare
That's really unfortunate. When modifying a GDScript in an external editor the inspector updates when refocusing the Godot editor, but I couldn't find any calls to It's probably triggered somewhere in |
Uuh, you're right. I'm positive I tried it out and didn't see it refresh 🤔 Looking at it now, it comes from This does the trick, but I'm not entirely sure of all the potential implications. The idea being: when we're not sure something changed or not, consider it might have, and call diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 8e1587997b..933d0a0f84 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -2246,6 +2246,13 @@ bool CSharpScript::_update_exports(PlaceHolderScriptInstance *p_instance_to_upda
} else {
p_instance_to_update->update(propnames, values);
}
+ } else if (placeholders.size()) {
+ for (PlaceHolderScriptInstance *instance : placeholders) {
+ Object *owner = instance->get_owner();
+ if (owner->get_script_instance() == instance) {
+ owner->notify_property_list_changed();
+ }
+ }
}
}
#endif |
It'd be nice to notify only if the file last modified date is newer than the last valid build time, so maybe something like this: diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 8e1587997b..9759db5a0a 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -2246,6 +2246,18 @@ bool CSharpScript::_update_exports(PlaceHolderScriptInstance *p_instance_to_upda
} else {
p_instance_to_update->update(propnames, values);
}
+ } else if (placeholders.size()) {
+ uint64_t script_modified_time = FileAccess::get_modified_time(get_path());
+ uint64_t last_valid_build_time = FileAccess::get_modified_time(GodotSharpDirs::get_res_temp_assemblies_dir().path_join(path::get_csharp_project_name() + ".dll"));
+
+ if (script_modified_time > last_valid_build_time) {
+ for (PlaceHolderScriptInstance *instance : placeholders) {
+ Object *owner = instance->get_owner();
+ if (owner->get_script_instance() == instance) {
+ owner->notify_property_list_changed();
+ }
+ }
+ }
}
}
#endif
I'm not sure if Lines 443 to 446 in 2d0ee20
We also do that when reloading C# assemblies: godot/modules/mono/csharp_script.cpp Lines 1144 to 1148 in 2d0ee20
|
Yeah, I was pondering the call to |
As a rule of thumb you should never call |
Humpf, actually the issue is this is only triggered when |
Yeah, not sure what the best way to handle this is. Should we have our own version of what's done in |
For me I have both settings unset and it seems to work, I guess it's because I have the C# script open in the Godot editor. But you are right that if I have
Maybe we can just change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me and works as expected. Thanks again for contributing to the usability of the .NET module.
684aa68
to
0818d01
Compare
Last push is simply squashing all commits, and using |
That shouldn't be necessary, Line 889 in 13a0d6e
Footnotes
|
Urh, sorry, I thought it was necessary for the key to be extracted in the first place. |
I don't think extracting works for C# either way, so all the other strings that we have with Maybe these strings need to be added to https://github.com/godotengine/godot-editor-l10n manually or implement C# support in extract_editor.py. |
So I guess having the |
Thanks! |
Can an editor option be provided so that the project can automatically perform C# compilation after the file is changed? |
Hello! There are already other issues discussing this |
Add a small warning in the inspector when C# scripts are out of sync with data we gathered during compilation. The warning is displayed if any C# script in the class hierarchy was modified since the last compilation, and disappears as soon as possible.
Sadly, the inspector is not refreshed ATM when the window is refocused (e.g. if you tab back from your external code editor). From my tests, this behaviour is not language-dependent, so it'd probably warrant a fix higher up (therefore, I didn't look how to do so in this PR).
I gladly take any suggestion for UI and wording. E.g. someone suggested to directly add a button/link to build directly from the warning. But I'm not sure how I feel about that.