-
-
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
Fix Label3D, TextMesh & Font not following project default theme in editor #89311
Conversation
scene/3d/label_3d.cpp
Outdated
for (const Ref<Theme> &theme : global_context->get_themes()) { | ||
List<Ref<Theme>> themes = global_context->get_themes(); | ||
if (Engine::get_singleton()->is_editor_hint()) { | ||
themes.push_front(ThemeDB::get_singleton()->get_project_theme()); // Preview in the editor properly. |
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.
// Preview in the editor properly.
Not sure if this comment is necessary
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.
To me it feels weird that it has to be done this way. I can remove the comment though.
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'm content either way
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.
Exactly the same code is used in the TextMesh
and by Font
to get the default font, so these might need the same change, but I have no idea if this is a correct way to fix it.
afbff81
to
ba86704
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 reason why it works is that the global theme context in editor does not contain project theme:
godot/scene/theme/theme_db.cpp
Lines 278 to 280 in 0ace0a1
if (!Engine::get_singleton()->is_editor_hint()) { | |
themes.push_back(project_theme); | |
} |
You are pushing it to front of the iterated theme list, so the Label3D checks it and finds the font (
get_font()
will always return something if a default font is assigned).
btw the get_fallback_theme()
code below is most likely dead, as fallback theme is the same as the last theme in the List above.
Thanks! |
Seems to fix #85693 without side effects, and I honestly have no idea why.