-
-
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
Add script class categories to EditorInspector. #32428
Conversation
dfea968
to
f611b86
Compare
Oh wait, I just realized that the current implementation omits the Script Variables section, even if the user is currently working on an unnamed script. That hasn't been accounted for. Also, we need to decide on what to do about properties that belong to intermediate scripts. Please see the Issue in the post for reference. Edit: Updated it. Went with the second option I suggested in the issue. |
f611b86
to
ea09a2b
Compare
I think that if there are no class_name in the script, we should not make the user believe there is one. So I think that in this situation the file name should be used as the section header. |
ea09a2b
to
a66e4d6
Compare
@groud Updated to show file names AND include proper icons. |
a66e4d6
to
414554f
Compare
1dc0f25
to
87193d5
Compare
Rebased |
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.
I tested this PR and it seems to work properly, really glad script classes are getting improvements 🎉
87193d5
to
3eb719e
Compare
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.
The _update_script_class_properties function look a little bit complex for what it does, but well, there might not be better way to implement it.
In any case, since it's inside a single function, it's likely ok to merge anyway.
3eb719e
to
14203fc
Compare
@aaronfranke @groud I realized that code was re-fetching the name/icon-path from the script rather than from the cached data in the EditorData. I've modified two more lines of code to pull from there instead (an optimization). |
@groud The only way that I can think of that you could improve the performance of it would be if the generic |
14203fc
to
644de52
Compare
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.
This is great, it even works with multiple inherited script classes!
Two notes:
-
The icon doesn't show up for nodes added with
add_custom_type
, but AFAIK this is going to be removed eventually in favor of the script class system, so this is fine. -
While testing, I noticed that changing the values of a property of an inherited script in the inspector doesn't call the getters and setters for that property (ex: changing Spatial Position in the above image does not work, but it works when not inherited). However, this bug also exists on master, so it's not a bug with this PR. I'll open a separate bug report for this.
@aaronfranke Also, as you can see in the OP, it even works if you have a script, then inherit a non-script-class, and then have a script class inherit that script. It works quite well. |
Thanks! |
@@ -3661,8 +3661,6 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p | |||
if (icon.is_null()) { | |||
icon = gui_base->get_theme_icon(ScriptServer::get_global_class_base(name), "EditorIcons"); | |||
} | |||
|
|||
return icon; |
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.
Since this is removed, what is the whole point of this if block?
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.
Good point, lines 3661-3663 are useless code now.
@willnationsdev Just a question, may #40161 allow you to simplify the implementation ? |
@groud No since ClassDB can only be aware of C++ level engine code. I'd need something like |
Is there any chance for this to be cherry-picked for 3.2? Only if it's trivial of course. |
Everything I did here should be compatible with 3.2.x, afaik. So, it should work out of the box for the most part if cherry-picked (very few, if any, conflicts). |
Not sure how up to date the commit I used is, but I can at least report that I've been using this as a cherry-pick in a 3.2 custom build for some time without issue. |
Cherry-picked for 3.2.4. |
@akien-mga in 3.2, this commit seems to break editor plugin tools, i.e. Zylann's HTerrain now missing vital properties in UI |
I posted an issue #43491 |
Closes godotengine/godot-proposals#109.
There isn't an icon showing beside DerivedB, but that is a bug that is unrelated to the mentioned Issue.
Here is an updated version that does away with the "Script Variables" section entirely and which always uses the script class name (if it's available) or the file name (capitalized, without spaces) so that they usually appear as a valid identifier (unless it's a filename that starts with a number or something).
In the example below, I have a non-script-class script in between two script classes:
Okay, here is the same code, but now I've changed it to show the file name and I went ahead and updated the icon rendering code so that it will fetch the most recent script class icon / base type icon PER individual script in the hierarchy.
Note that the code now anticipates that if it is a category, and the category's name does not match an existing ClassDB or ScriptServer record, AND the
hint_string
contains a valid file path, then it will attempt to load that file path as a script so that it can load the script and fetch the appropriate icon from its information.