Jump to content

A C# babe in the woods (weeds?) - KSPScienceLibrary


Recommended Posts

I am very OaCrD and can't stand having errors in my log files. So, in an effort to broaden my horizons I've decided to delve into C# with MonoDevelop.

Nothing has been done with this mod since late June, source is available and I'm game. All aboard; first stop, KSPScienceLibrary. I updated the references and built a release .dll file. Things look good except for one area, this:

NullReferenceException: Object reference not set to an instance of an object

at FlightGlobals.get_Bodies () [0x00000] in <filename unknown>:0

at KSPScienceLibrary.Awake () [0x00000] in <filename unknown>:0

UnityEngine.GameObject:Internal_AddComponentWithType(Type)

UnityEngine.GameObject:AddComponent(Type)

AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)

AddonLoader:StartAddons(Startup)

:MoveNext()

UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)

UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)

:MoveNext()

UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)

UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)

GameDatabase:StartLoad()

:MoveNext()

UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)

UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)

LoadingScreen:Start()

Can anyone walk me through fixing this? In the meantime, I'll be researching all those routines.

P.S. I've no plans to release anything nor to take over; this is just for my private learning and use. But, if the license allows it, I might make the new file available ... sans support. (Until I learn better.)

Link to comment
Share on other sites

You may first use a more meaningful title for your thread, to at least give people a wish to read it.

Then, no need to dive into all methods given in the log, you would first look into KSPScienceLibrary.Awake which is the first one where the issue could be (the others below are not in your control, the one above messsed up because it have kind of bad parameter(s) already).

Link to comment
Share on other sites

Does this exception come up every time Science Library loads?

It might be that Awake() is not the right place for it to be checking the FlightGlobals.Bodies list; it is probably too soon in the loading process, so the FlightGlobals instance hasn't finished, or maybe even started, loading yet. The Unity docs go over the MonoBehaviour load order.

It might also be that this happens because the Bodies list isn't loaded in that particular scene, the VAB or SPH for instance.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...