sinai-dev / UnityExplorer

An in-game UI for exploring, debugging and modifying IL2CPP and Mono Unity games.
GNU General Public License v3.0
2.29k stars 345 forks source link

Exceptions with UI on startup #54

Closed akintos closed 3 years ago

akintos commented 3 years ago

Game issue occurs on: Wasteland 3

UnityExplorer version: MelonLoader Il2Cpp 3.3.10

MelonLoader version: 0.3.0.0

Description of issue: Failes to initialize UI on load, blank box is displayed

Unity log link: https://pastebin.com/E13azkEn

Mod Loader log link: https://pastebin.com/z9qktrzx

Works fine on MelonLoader v0.2.7.4, UnityExplorer v3.1.12.

sinai-dev commented 3 years ago

Should be an easy fix here, thanks

sinai-dev commented 3 years ago

Ok it went a bit deeper than I thought but I'm pretty sure I fixed it. Let me know how this release goes for you https://github.com/sinai-dev/UnityExplorer/releases/tag/3.3.11

akintos commented 3 years ago

Thank you for the update.

이미지 183

SetColorBlock raises TargetInvocationException and another series of NullReferenceException has occurred with UIFactory.CreateScrollbar

Unity log link: https://pastebin.com/ix3zsx3H

Mod Loader log link: https://pastebin.com/9pAtx0xF

sinai-dev commented 3 years ago

Hmm ok, upon further inspection it seems that MelonLoader is not unstripping the UnityEngine.UI.dll module.

Could you try with BepInEx instead?

Hopefully this works, otherwise I'm afraid I'm not sure we'll get much further.

akintos commented 3 years ago

이미지 184

Unfortunately, using BepInEx didn't help.

sinai-dev commented 3 years ago

Is that from your first launch with BepInEx? I don't see any unstripping going on in the BepInEx log.

Well, not too sure what else to try, we need to get the unstripped UnityEngine.UI to be loaded somehow. Could you try just dropping this file into your BepInEx\unhollowed\ directory? (and unzipping it)

UnityEngine.UI.dll.zip

sinai-dev commented 3 years ago

Hmm, that's odd, I'm setting the ColorBlock essentially the same way with 3.1.12 - https://github.com/sinai-dev/UnityExplorer/blob/12cd718f12cf35eaee7964940123de8fbd191fb9/src/UI/UIFactory.cs#L83

Strange that this doesn't throw the same exception then. I'll download the 2019.4.4 editor and have a look myself.

akintos commented 3 years ago

Sorry, I dropped UnityEngine.UI.dll into wrong folder. Now it says Exception in IL2CPP-to-Managed trampoline, not passing it to il2cpp

[Error  :Unhollower] Exception in IL2CPP-to-Managed trampoline, not passing it to il2cpp: System.NullReferenceException: Object reference not set to an instance of an object
  at UnityExplorer.ExplorerCore.Update () [0x00001] in <9e84ace0bb214af5a07cc7f5d0126436>:0 
  at UnityExplorer.ExplorerBepInPlugin+ExplorerBehaviour.Update () [0x00001] in <9e84ace0bb214af5a07cc7f5d0126436>:0 
  at (wrapper dynamic-method) UnityExplorer.ExplorerBepInPlugin+ExplorerBehaviour.Trampoline_VoidThisUnityExplorer.ExplorerBepInPlugin+ExplorerBehaviourUpdate(intptr,UnhollowerBaseLib.Runtime.Il2CppMethodInfo*)
sinai-dev commented 3 years ago

@Akintos need the full log to know whats happening there, most likely the first error will tell me what failed.

akintos commented 3 years ago

There's nothing more to see. BepInEx log file and nothing useful in UnityPlayer log.

sinai-dev commented 3 years ago

Fair enough, strange. And you're sure 3.1.12 still works with older ML?

akintos commented 3 years ago

Yes, there is a bug with ForceUnlockCursor though. It works fine if you do not hide and reopen the UI.

[10:22:35.654] Registered mono type MelonLoader.Support.MelonLoaderComponent in il2cpp domain
[10:22:35.668] Registered mono type UnhollowerRuntimeLib.DelegateSupport+Il2CppToMonoDelegateReference in il2cpp domain
[10:22:35.678] ------------------------------
[10:22:35.678] Unity 2019.4.4
[10:22:35.678] OS: Microsoft Windows NT 10.0.19042.0
[10:22:35.679] ------------------------------
[10:22:35.679] Name: Wasteland 3
[10:22:35.679] Developer: InxileEntertainment
[10:22:35.679] Type: Il2Cpp
[10:22:35.680] ------------------------------
[10:22:35.680] Using v0.2.7.4 Open-Beta
[10:22:35.680] ------------------------------
[10:22:35.878] No Plugins Loaded!
[10:22:35.879] ------------------------------
[10:22:35.879] UnityExplorer v3.1.12 by Sinai
[10:22:35.880] Game Compatibility: Universal
[10:22:35.880] ------------------------------
[10:22:36.911] [UnityExplorer] Initializing Legacy Input support...
[10:22:37.030] [UnityExplorer] UnityExplorer 3.1.12 initialized.
[10:22:37.870] [UnityExplorer] Loaded UI bundle
[10:22:38.977] [UnityExplorer] Initialized UnityExplorer UI.
[10:23:23.314] [UnityExplorer] [Error] UnhollowerBaseLib.Il2CppException: System.NullReferenceException: Object reference not set to an instance of an object.
  at UnhollowerBaseLib.Il2CppException.RaiseExceptionIfNecessary (System.IntPtr returnedException) [0x00018] in <583918877c33430fa1dd04c070650e0d>:0 
  at UnityEngine.Behaviour.set_enabled (System.Boolean value) [0x00048] in <513cfff6bb57493c89c920b5b2f59ed1>:0 
  at UnityExplorer.UI.ForceUnlockCursor.SetEventSystem () [0x0006b] in <e82e5b1eb803461fa4acb8f1f52b036a>:0 
  at UnityExplorer.ExplorerCore.SetShowMenu (System.Boolean show) [0x00027] in <e82e5b1eb803461fa4acb8f1f52b036a>:0 
  at UnityExplorer.ExplorerCore.set_ShowMenu (System.Boolean value) [0x00000] in <e82e5b1eb803461fa4acb8f1f52b036a>:0 
  at UnityExplorer.ExplorerCore.Update () [0x0003d] in <e82e5b1eb803461fa4acb8f1f52b036a>:0 
  at UnityExplorer.ExplorerMelonMod.OnUpdate () [0x00001] in <e82e5b1eb803461fa4acb8f1f52b036a>:0 
  at MelonLoader.MelonHandler.OnUpdate () [0x000a3] in <1439d668687c44d0920b0e0ecea592c0>:0 
sinai-dev commented 3 years ago

Update again: Finally figured out what's going on here.

The issue is simply that I am creating the UI too quickly. Looks like this game is doing some stuff to destroy all GameObjects on startup, so I just need to wait a second or so for that.

Fix will be pushed shortly.

sinai-dev commented 3 years ago

Fixed :) https://github.com/sinai-dev/UnityExplorer/releases/tag/3.3.12

akintos commented 3 years ago

So the problem was UI being initialized too early? Thank you very much for the fix!

sinai-dev commented 3 years ago

Yep, can't believe I didn't think of it sooner. I used to wait a bit before creating the UI but recently I started making it straight away, seems that some games still don't like that.