Jump to content

[help] My plugin stops working when player reverts launch


Recommended Posts

I've been banging my head against the wall here for months, and I can't figure out why my plugin KeyNode ceases to work when the player reverts their launch.
I've added debug code to the void Update and got no feedback, it's like the plugin was unloaded and never loaded again

any ideas?

Link to comment
Share on other sites

It throws an uncaught exception in Awake and its MonoBehaviour ends up getting disabled (MonoBehaviour.enabled = false) when initializing for the second+ time. That's why you don't see any output from Update on subsequent flight scenes

ArgumentException: An element with the same key already exists in the dictionary.
	System.Collections.Generic.Dictionary`2[UnityEngine.KeyCode,Callback].Add (KeyCode key, .Callback value)
	KeyNode.KeyNode.Awake ()
	UnityEngine.GameObject:AddComponent(Type)
	AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
	AddonLoader:StartAddons(Startup)
	AddonLoader:OnLevelLoaded(GameScenes)
	AddonLoader:OnSceneLoaded(Scene, LoadSceneMode)
	UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)

 

Link to comment
Share on other sites

The exception in the log was the first clue. I looked at the code and didn't see any reason why that would prevent a simple print statement made in Update from working, so I wrote another small addon that checked out KeyNode's state. There were three possibilities as to why Update wasn't running:

  1. the component had been destroyed due to the uncaught exception in Awake. I've never seen this before, but thought it could be something AddonLoader does on an unhandled exception
  2. the GameObject wasn't active
  3. the MonoBehaviour was disabled (by Unity?)

Turns out #3 was your problem

 

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...