newman55 / unity-mod-manager

UnityModManager
MIT License
424 stars 99 forks source link

EnableReloading attribute on class, but CanReload is still false #86

Open LoganDark opened 3 years ago

LoganDark commented 3 years ago

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 commented 3 years ago
typeof(UnityModManager.ModEntry).GetProperty("CanReload").SetValue(entry, true, null);

works 🤡

newman55 commented 3 years ago

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

LoganDark commented 3 years ago

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

newman55 commented 3 years ago

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

LoganDark commented 1 year ago

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.