-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Refactor Object metadata #59452
Refactor Object metadata #59452
Conversation
The feature itself looks good to me. However, the "+" icon to the left of "Add Metadata" should have more spacing. Right now, the icon looks like it's too close to the text. It might be worth adding some vertical padding above the button too. PS: Does this PR supersede #30765? If so, maybe #30765 could be salvaged for |
Can you make a small mock up or give me feedback what you would change in code?
It does, will specify in the description, thanks! |
is there any harm to people potentially assuming meta data is functionality of Node? because the UI suggests that. alternatively, a separate Tab could be introduced like this plugin does: |
@h0lley No, metadata is a property of everything, not just nodes. I prefer not add a separate tab and keep everything as part of the inspector. This allows taking better advantage of the existing editors as well as the possibility of animating these values. |
While I do welcome the feature, metadata is something more advanced users may want or need access to. I'm afraid this bit of extra info may be a tad overwhelming for starting users when displayed right there, as the difference between normal properties and metadata may not readily be apparent. |
@Mickeon The way its proposed to work is that, if you don't know what it is or not need it, you will not use it for the most part. |
Could an editor or project setting be added to show all metadata, including ones that start with an underscore? Being able to see all metadata could be useful for debugging.
It could be made to look like the button in the Array and Dictionary editors: |
Perhaps this Editor setting could be set to "None" (completely hide the feature, depending on the workflow one may not need it), "Omit Underscore" (the default and current behaviour), "All" (display all metadata). |
Here are my changes for the button (made before @fire-forge posted their suggestion): diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 11df8c88f3..558e5b2b1e 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -2959,12 +2959,15 @@ void EditorInspector::update_tree() {
if (!hide_metadata) {
CenterContainer *cc = memnew(CenterContainer);
+ // Add some spacing above and below the button.
+ cc->set_custom_minimum_size(Size2(0, 50 * EDSCALE));
main_vbox->add_child(cc);
Button *add_md = memnew(Button);
- add_md->set_flat(true);
+ add_md->set_flat(false);
add_md->set_text(TTR("Add Metadata"));
add_md->set_focus_mode(Control::FOCUS_NONE);
add_md->set_icon(get_theme_icon("Add", "EditorIcons"));
+ add_md->add_theme_constant_override(SNAME("hseparation"), 8 * EDSCALE);
add_md->connect("pressed", callable_mp(this, &EditorInspector::_add_meta_callback));
cc->add_child(add_md);
} This is outdated now, except for the part about the CenterContainer minimum size (which adds some spacing above and below the button): |
805de36
to
957cacd
Compare
@reduz, I know what you say here is correct:
However, notice that in the mockup it appears inside "Node". There are "CanvasItem" and "Node" sections in the inspector: So if you
Then consider the other part that @h0lley was saying
Something like this: I haven't tested the build. So perhaps you already did that and I'm unaware. Otherwise as @h0lley said the UI suggest it is part of Node. |
EDIT: |
Object is not instanceable in the editor, so it doesn't matter. As mentioned, script is also part of Object. So it's consistent that everything exposed in Object and Node show up together. |
This sounds like a bug in ConfirmationDialog, will give it a check.
I will change it to remove types that can be conflicting, although for Object it seems broken somehow. |
* API kept the same (Although functions could be renamed to set_metadata/get_metadata in a later PR), so not much should change. * Metadata now exposed as individual properties. * Properties are editable in inspector (unless metadata name begins with _) under the metadata/ namespace. * Added the ability to Add/Remove metadata properties to the inspector. This is a functionality that was requested very often, that makes metadata work a bit more similar to custom properties in Blender.
ea3bbcb
to
09b951b
Compare
add_meta_type = memnew(OptionButton); | ||
for (int i = 0; i < Variant::VARIANT_MAX; i++) { | ||
if (i == Variant::NIL || i == Variant::RID || i == Variant::CALLABLE || i == Variant::SIGNAL) { | ||
continue; //not editable by inspector. |
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.
continue; //not editable by inspector. | |
continue; // Not editable by inspector. |
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.
@KoBeWi It seems the icon for "Resource" is just missing because, for some reason, we never really needed to use it until now. I suppose it can be added in a subsequent PR. |
Thanks! |
Note: I added the
|
How can we know the list of editor metadata ? |
From scene file. |
Well, when I open the file in an external editor, it does show me the metadata applied yes. But not all of the possible ones, and that's what I want to know, how many are they ? what are they, and even better, what's their names to call them ?? |
There is no list of "possible" metadata, the values are assigned dynamically. The best you can do is search the C++ source code for |
This is a functionality that was requested very often, that makes metadata work a bit more similar to custom properties in Blender.
How it looks:
So, as a note, as metadata is now user visible, make sure to make the ones you don't intend to be seen begin with underscore ("_"). Such as
This way, the editor will omit it, but it will still be saved.
Supersedes #30765