OnResolutionChanged throws null refrence exception when using First-person Auto-Walking mod
See original GitHub issuefrom #938 comments:
Found some possible issues when testing in-game. Note: I’m using First-person Auto-Walking mod, rather than the more commonly used First Person Camera (Updated) mod. First, if a tool is active, the overlays are still rendering in first person cam. At the very least this is bad for fps. Second, I press
Esc
to exit the first person cam, and TM:PE toolbar still visible etc. (this is correct). However, when I pressEsc
to exit the toolbar, the toolbar does get closed but thePause Menu
is also displayed. It’s like the UI fsm somehow got confused. Could it be picking up theEsc
I used to exit first person cam thinking it’s closed the menu and no longer needs to trapEsc
?
Actually, it doesn’t look like the TM:PE toolbar is getting closed; I suspect it thinks it’s already closed (due to
Esc
press while exiting the first person cam): Steps:
- Open TMPE toolbar, select lane connector tool (for example)
- Tab key= go in to first person autowalking cam
- Esc key = exit first person cam
- Esc key = should only close TMPE toolbar, but it doesn’t; instead it shows Pause Menu
@aubergine10 The problem you raised is due to an exception preventing the rest of the code from running:
NullReferenceException: Object reference not set to an instance of an object
at ColossalFramework.UI.UIComponent.OnResolutionChanged (Vector2 previousResolution, Vector2 currentResolution) [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIView.OnResolutionChanged (Vector2 oldSize, Vector2 currentSize) [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIView.OnResolutionChanged (Int32 oldSize, Int32 currentSize) [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIView.OnResolutionChanged () [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIView.OnEnable () [0x00000] in <filename unknown>:0
UnityEngine.Behaviour:set_enabled(Boolean)
ColossalFramework.UI.UIView:ShowView(Boolean)
ColossalFramework.UI.UIView:Show(Boolean)
IINS.AutoWalking.MonoCamera:UpdateFreeCamera()
IINS.AutoWalking.MonoCamera:OnDestroy()
IINS.AutoWalking.WalkingCamera:OnDestroy()
(Filename: Line: -1)
NullReferenceException: Object reference not set to an instance of an object
at ColossalFramework.UI.UIComponent.OnResolutionChanged (Vector2 previousResolution, Vector2 currentResolution) [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIView.OnResolutionChanged (Vector2 oldSize, Vector2 currentSize) [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIView.Update () [0x00000] in <filename unknown>:0
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (6 by maintainers)
Top GitHub Comments
at 99.9% it’s https://github.com/CitiesSkylinesMods/TMPE/pull/938
Here is a sort sum up where I got stuck. As you already know from the stack trace, the issue is triggered when IINS.AutoWalking.WalkingCamera:OnDestroy() is called in certain scenario, which eventually leads to ColossalFramework.UI.UIView.Show(), public static function. This function tries to iterate on ColossalFramework.UI.UIView.sUIViews.Values, and calls the non existing UIView object function.
Here is the sUIViews dic.
private static Dictionary<string, UIView> sUIViews = new Dictionary<string, UIView>();
Let’s find our way back to TMPE, shall we?
I could only find local Show() function inside TMPE namespace, and no call for ColossalFramework.UI.UIView.Show(). Furthermore, I could neither find exact call for ColossalFramework.UI.UIView.sUIViews Values, nor Keys. I might not made a detailed search although…
Is TMPE updating this dictionary?
Something definitely nulling out that UIView inside that dictionary, but could not yet find out where.