unity-mod-manager icon indicating copy to clipboard operation
unity-mod-manager copied to clipboard

EnableReloading attribute on class, but CanReload is still false

Open LoganDark opened this issue 3 years ago • 5 comments

The entire source file is this:

using UnityModManagerNet;

namespace Mod {
	[EnableReloading]
	static class Main {
		static bool Load(UnityModManager.ModEntry entry) {
			UnityModManager.Logger.Log(string.Format("hello test. reload: {0}", entry.CanReload), "[Mod] ");
			return true;
		}
	}
}

It prints false. I opened the DLL in dnSpy and it looks like the annotation is still there. What gives? I would have expected this check to pass:

https://github.com/newman55/unity-mod-manager/blob/c525b6f19f09b35233b5be3621dcaff75ad8d55d/UnityModManager/ModManager.cs#L600-L602

The reload button simply does not show up in the ctrl+f10 menu.

LoganDark avatar Sep 03 '21 15:09 LoganDark

typeof(UnityModManager.ModEntry).GetProperty("CanReload").SetValue(entry, true, null);

works 🤡

LoganDark avatar Sep 03 '21 15:09 LoganDark

Strange, it usually always worked. Because the method and the property are in the same object.

newman55 avatar Sep 03 '21 15:09 newman55

Weird, looks like reloading also doesn't load the new assembly properly, still getting a log message I removed even after wiping all the DLLs (including the cached one) and hitting reload. Looks like reload is just generally too unreliable, just going to be restarting the game as usual then

LoganDark avatar Sep 03 '21 16:09 LoganDark

Yes it is, with each new unity version, the restart becomes more and more difficult.

newman55 avatar Sep 03 '21 18:09 newman55

I discovered over a year later by looking through UMM's code that you must declare a minimum manager version of at least 0.13. This is not documented anywhere, but adding this to the info.json makes it work

	"ManagerVersion": "0.23.5.0",

This issue can be closed once the wiki says that you need this in order to make reloading work.

LoganDark avatar Oct 03 '22 15:10 LoganDark