Fix this type of issue is easy : just move the initialization from constructor to Awake.
I was wanting to fix and create pull requests, but can't figure out how to easily compile SCANsat project (using Visual Studio on Windows).
UnityException: get_gameObject is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'SCANtoolbar' on game object 'SCANtoolbar'.
See "Script Serialization" page in the Unity Manual for further details.
at (wrapper managed-to-native) UnityEngine.Component.get_gameObject(UnityEngine.Component)
at SCANsat.SCAN_Toolbar.SCANtoolbar..ctor () [0x0000d] in <532e0c7735694646a2dba646ef08b593>:0
UnityEngine.GameObject:Internal_AddComponentWithType(Type)
UnityEngine.GameObject:AddComponent(Type) (at C:\buildslave\unity\build\Runtime\Export\Scripting\GameObject.bindings.cs:222)
AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
AddonLoader:StartAddons(Startup)
AddonLoader:OnLevelLoaded(GameScenes)
AddonLoader:OnSceneLoaded(Scene, LoadSceneMode)
UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode) (at C:\buildslave\unity\build\Runtime\Export\SceneManager\SceneManager.cs:244)
As per the below trace from Player.log.
Fix this type of issue is easy : just move the initialization from constructor to Awake.
I was wanting to fix and create pull requests, but can't figure out how to easily compile SCANsat project (using Visual Studio on Windows).