question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OnResolutionChanged throws null refrence exception when using First-person Auto-Walking mod

See original GitHub issue

from #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. image Second, I press Esc to exit the first person cam, and TM:PE toolbar still visible etc. (this is correct). However, when I press Esc to exit the toolbar, the toolbar does get closed but the Pause Menu is also displayed. It’s like the UI fsm somehow got confused. Could it be picking up the Esc I used to exit first person cam thinking it’s closed the menu and no longer needs to trap Esc?

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): image Steps:

  1. Open TMPE toolbar, select lane connector tool (for example)
  2. Tab key= go in to first person autowalking cam
  3. Esc key = exit first person cam
  4. 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:closed
  • Created 3 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
krzychu124commented, Feb 28, 2022
1reaction
baizsofcommented, Jul 21, 2020

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.

ShowViewPNG

Read more comments on GitHub >

github_iconTop Results From Across the Web

SaveGameInfo Null Reference Exception after Updating a ...
Two days ago I was playing with a bunch of mods that were a version or two old, just to avoid any troubles...
Read more >
c# - null reference exception in app.UseExceptionHandler ...
I want to log exception into database, the exception is not null and it goes to the if() loop, but unfortunately it throws...
Read more >
Fix Null Reference Exception in Unity - YouTube
Here I have another debugging tutorial on how to fix a NullReferenceException error in Unity. This lesson will teach you more about ...
Read more >
Null ref in Item when equiping in third person view
NullReferenceException : Object reference not set to an instance of an object Opsive.UltimateCharacterController.Items.Item.
Read more >
Untitled
Antenna problems and solutions, How to set auto forward in gmail, Yelawolf trunk muzik iii ... Backsound one call away, Game arcade co...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found