-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore NREs from FlightGlobals.ActiveVessel (fixes #33)
Happens during compilation of internal spaces according to @JonnyOThan
- Loading branch information
Showing
3 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5002506
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhh you probably just should have checked the current game scene
5002506
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? What? Why?
5002506
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flightglobals don’t exist during the loading scene. Allowing the exception to be thrown and just silently swallowing an exception is just…not great.
Doing logic inside constructors is also generally discouraged in unity. Awake or Start is better depending on what you need. There’s also a a few virtual methods on InternalModel but I’d have to go review the best way to use them.
5002506
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My class is being instantiated at a time when it doesn't make sense for it to exist, and a simple accessor property that can be
null
is instead throwing an exception because it has a weird initialization dependency and its use probably wasn't thought through very deeply. A whole lot of things are "not great" here already.5002506
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More importantly,
FlightGlobals.getMainBody()
apparently callsActiveVessel
internally, so the exception is probably still thrown. Sigh.5002506
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything gets instantiated during loading for prefabs.
if this initialization code were in Start instead, it wouldn’t run in the flight scene. The loading scene is meant for setting up the prefab (in Awake mostly) so that it can be cloned for each instance.