Merge pull request #25650 from willnationsdev/script-icon
Fix script class icons looking for paths at runtime
This commit is contained in:
commit
6c243326bd
1 changed files with 12 additions and 8 deletions
|
@ -3494,16 +3494,20 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
||||||
tokenizer->advance();
|
tokenizer->advance();
|
||||||
|
|
||||||
if ((tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING)) {
|
if ((tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING)) {
|
||||||
Variant constant = tokenizer->get_token_constant();
|
#ifdef TOOLS_ENABLED
|
||||||
String icon_path = constant.operator String();
|
if (Engine::get_singleton()->is_editor_hint()) {
|
||||||
|
Variant constant = tokenizer->get_token_constant();
|
||||||
|
String icon_path = constant.operator String();
|
||||||
|
|
||||||
String abs_icon_path = icon_path.is_rel_path() ? self_path.get_base_dir().plus_file(icon_path).simplify_path() : icon_path;
|
String abs_icon_path = icon_path.is_rel_path() ? self_path.get_base_dir().plus_file(icon_path).simplify_path() : icon_path;
|
||||||
if (!FileAccess::exists(abs_icon_path)) {
|
if (!FileAccess::exists(abs_icon_path)) {
|
||||||
_set_error("No class icon found at: " + abs_icon_path);
|
_set_error("No class icon found at: " + abs_icon_path);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_class->icon_path = icon_path;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
p_class->icon_path = icon_path;
|
|
||||||
|
|
||||||
tokenizer->advance();
|
tokenizer->advance();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue