newman55 / unity-mod-manager

UnityModManager
MIT License
425 stars 99 forks source link

PlatformNotSupportedException for newer Unity games using .NET 2.0 #20

Open ghost opened 5 years ago

ghost commented 5 years ago

For Risk of Rain 2, I am unable to inject error free because of Harmony's reliance on API no longer existent in Unity for certain games. See some people with the exact same issue for more info:

https://github.com/BepInEx/BepInEx/issues/67

Thankfully, the assembly install feature is still perfectly fine; I was able to avoid the error at: https://github.com/newman55/unity-mod-manager/blob/master/UnityModManager/Injector.cs#L96 by simply removing doorstop support for the game.

However, I ran into the issue again when the UI loaded at: https://github.com/newman55/unity-mod-manager/blob/master/UnityModManager/UI.cs#L81.

I tried to find a suitable replacement for the patch, but could not as my UI game is weak. Instead, I commented the patch line out and I was able to view the UI with no errors to be found. That said, it obviously did not work as intended since the cursor hid underneath the mod manager UI:

2019-04-01_22-10-58

I would love to incorporate UMM with the new Risk of Rain installment, but can't do so until either:

A) The lockCursor fix is replaced with a non-patching solution B) There's a \<PatchUI>false\</PatchUI> config option or something that disables the patch to the setter. We'd just have to put up with the cursor being underneath the UI.

Of course, I don't actually know if the mouse cursor issue was caused by commenting out the patch or not. If not, it's an entirely separate issue from this one.

This is my GameInfo configuration:

<GameInfo Name="Risk of Rain 2">
    <Folder>Risk of Rain 2</Folder>
    <ModsDirectory>Mods</ModsDirectory>
    <ModInfo>Info.json</ModInfo>
    <EntryPoint>[Assembly-CSharp.dll]RoR2.UI.MainMenu.MainMenuController.Init:After</EntryPoint>
</GameInfo>
newman55 commented 5 years ago

You're right, this patch makes the cursor work. Theoretically, when you open the UMM, you can turn it on manually, if the game does not intercept him again. Cursor.visible = true; Cursor.lockState = CursorLockMode.None;

newman55 commented 5 years ago

@wbspeicher There is a similar discussion in github harmony and they have found a solution. https://github.com/pardeike/Harmony/issues/172

You need to copy mscorlib.dll to the managed folder. https://www.dropbox.com/s/gxxg4gpe9hedezk/mscorlib.dll?dl=1

For me it works. But the cursor still does not.

newman55 commented 5 years ago

@wbspeicher I fixed the cursor. Link to the test build. https://www.dropbox.com/s/o72ehfmqia1pncp/UnityModManager.testbuild.zip?dl=1 Test it and let me publish the update or not. But mscorlib.dll still needs to be downloaded separately.

ghost commented 5 years ago

@newman55 Those builds do work. I can't see what you did, but the UI loads fine and the cursor is on top.

Also, this coincidentally happened today: https://www.pcgamer.com/risk-of-rain-2-devs-talk-hitting-500000-players-mod-support-and-whats-coming-next

Looks like UMM could be in business for a while!

ChrisGangs commented 5 years ago

Hey i've been following this thread to get certain Risk of rain mods working with UMM. And thanks to you guys i was successful however. The Mscorlib.DLL causes the host to be the only one to start the game while others are forced to spectate. I replaced the Mscorlib in the Managed folder with the other one. Am i missing a step?

ghost commented 5 years ago

@ChrisGangs, I did not have an issue when I hosted or joined a server with my friends. Does undoing the replace of mscorlib fix the issue for you? If not, it would be caused by something else.

ChrisGangs commented 5 years ago

@wbspeicher yes replacing the mscorlib makes multiplayer work, but then im back to square one with. PlatformNotSupportedException