Godot导出Windows版本图标未更换的问题

问题

用Godot Editor导出项目的Windows版本,虽然设置了rcedit工具和自制的Windows程序图标,但是导出的项目可执行文件的图标并没有被更换。
rceidt
windows_native_icon

调查过程和解决方法

用Visual Studio打开项目可执行文件,可以确认程序所用图标名称为"GODOT_ICON"。
字符串"GODOT_ICON"只出现在godot\platform\windows\godot_res.rc文件中:
在这里插入图片描述
这确认了Godot导出Windows版本时并没有用rcedit工具将Godot的缺省图标替换为设置的自制图标。
继续调查Godot没有调用rcedit工具的原因。
字符串"Rcedit"只出现在godot\platform\windows\export\export.cpp:

Error EditorExportPlatformWindows::modify_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
    
    
	if (p_preset->get("application/modify_resources")) {
    
    
		_rcedit_add_data(p_preset, p_path);
	}
	return OK;
}

Error EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
    
    
...
		add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), TTR("Could not start rcedit executable. Configure rcedit path in the Editor Settings (Export > Windows > Rcedit), or disable \"Application > Modify Resources\" in the export preset."));
...

bool EditorExportPlatformWindows::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
    
    
...
	if (p_preset->get("application/modify_resources") && rcedit_path.empty()) {
    
    
		err += TTR("The rcedit tool must be configured in the Editor Settings (Export > Windows > Rcedit) to change the icon or app information data.") + "\n";
	}

这些信息说明:除了要配置rcedit工具,还要确保"Application > Modify Resources"(application/modify_resources)开关是打开的。
找到这个application/modify_resources开关:
windows_export
顺便把下面的“应用->图标”属性值也改好了。

修改后再次导出,在资源管理器中查看:程序图标没有更新;用Visual Studio打开exe文件查看,程序图标确实换了,说明前面的修改确实生效了。
考虑到资源管理器显示的程序图标可能有缓存,注销后重新登录,这次在资源管理器弹出菜单中选择“查看”的不同方式,除了“超大图标”和“大图标”,其它查看方式的图标显示都更新了。
考虑到超大图标和大图标可能缓存时间更长,暂时不管了。午睡后再看一遍,搞定!

猜你喜欢

转载自blog.csdn.net/feiyunw/article/details/127670120
今日推荐