Skip to content

"UnityException: get_dataPath is not allowed to be called from a MonoBehaviour constructor" in debug mode #85

@Lisias

Description

@Lisias

don't know if this has any effect on release builds. If you're not seeing any negative effects it's probably fine, but this kind of thing can make it difficult to use debug mode when these mods are installed.

[LOG 09:52:43.789] [AddonLoader]: Instantiating addon 'Startup' from assembly 'KSPe.Light.HLAirshipsCore'
[EXC 09:52:43.793] UnityException: get_dataPath is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'Startup' on game object 'Startup'.
See "Script Serialization" page in the Unity Manual for further details.
    KSPUtil.get_ApplicationRootPath () (at <4b449f2841f84227adfaad3149c8fdba>:0)
    KSPe.Globals.Init () (at <92b16042a579443e9cbbd4e174562dd7>:0)
    KSPe.Globals`1[T].Get (System.Type type) (at <92b16042a579443e9cbbd4e174562dd7>:0)
    KSPe.Globals`1[T].get_Log () (at <92b16042a579443e9cbbd4e174562dd7>:0)
    KSPe.Util.Log.Logger.CreateForType[T] (System.String forceThisNamespace, System.Boolean useClassNameToo, System.Int32 skipStackLevels) (at <92b16042a579443e9cbbd4e174562dd7>:0)
    KSPe.Startup..cctor () (at <92b16042a579443e9cbbd4e174562dd7>:0)
    Rethrow as TypeInitializationException: The type initializer for 'KSPe.Startup' threw an exception.
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.GameObject:AddComponent(Type)
    AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
    AddonLoader:StartAddons(Startup)
    <LoadObjects>d__90:MoveNext()
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    <CreateDatabase>d__71:MoveNext()
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    GameDatabase:StartLoad()
    <LoadSystems>d__11:MoveNext()
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    LoadingScreen:Start()

https://forum.kerbalspaceprogram.com/topic/207891-ksp-131-hooligan-labs-airships-core-7015-2025-0826/page/3/#findComment-4479840

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions