I don’t have Unity installed right now, but that probably means that they decided to re-set the icon on their own.
You would need to add a window message hook that intercepts the attempts to change icon and passes your saved icons instead.
In the GameMaker/C++ version that looks like the following:
LRESULT window_command_proc_hook(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
if (msg == WM_SETICON && window_icon_hook.enable) {
HICON icon;
switch (wp) {
case ICON_SMALL:
icon = window_icon_hook.icons[0];
break;
case ICON_BIG:
icon = window_icon_hook.icons[1];
break;
default: icon = NULL;
}
if (icon != NULL) lp = (LPARAM)icon;
}
return CallWindowProc(window_icon_hook.base, hwnd, msg, wp, lp);
}
void window_icon_hook_ensure(HWND hwnd) {
if (window_icon_hook.base == nullptr) {
window_icon_hook.base = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)window_command_proc_hook);
}
}
As ever, all function signatures and typedefs can be taken from pinvoke.net