Debug throwing exceptions
Posted: Mon May 29, 2023 7:18 pm
Hi! I'm trying to get some C# script to check the dialogue system for the value of a boolean. When a sentence in a conversation is had, the boolean "InLove" turns from false to true and the character follows the player.
I wrote this in the monobehaviour
public bool InLove = DialogueLua.GetVariable("InLove").isBool;
And then later in the Update part of the script wrote this:
if (Lua.IsTrue("(InLove")) {....}
which leads to the script that makes that sprite follow the player.
But I keep getting isdebugbuild exceptions and the program crashes. The actual compiler errors are:
UnityException: get_isDebugBuild is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'FollowLove' on game object 'Danni'.
See "Script Serialization" page in the Unity Manual for further details.
PixelCrushers.DialogueSystem.Lua.RunRaw (System.String luaCode, System.Boolean debug, System.Boolean allowExceptions) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:250)
PixelCrushers.DialogueSystem.Lua.Run (System.String luaCode, System.Boolean debug, System.Boolean allowExceptions) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:129)
PixelCrushers.DialogueSystem.Lua.Run (System.String luaCode, System.Boolean debug) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:139)
PixelCrushers.DialogueSystem.DialogueLua.InitializeChatMapperVariables () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/DB/DialogueLua.cs:119)
PixelCrushers.DialogueSystem.DialogueLua..cctor () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/DB/DialogueLua.cs:88)
Rethrow as TypeInitializationException: The type initializer for 'PixelCrushers.DialogueSystem.DialogueLua' threw an exception.
FollowLove..ctor () (at Assets/Scripts/FollowLove.cs:16)
Do you know what I am doing wrong here? I feel like it's probably something simple about how the C# script is talking to Lua, but I don't know what it is.
I wrote this in the monobehaviour
public bool InLove = DialogueLua.GetVariable("InLove").isBool;
And then later in the Update part of the script wrote this:
if (Lua.IsTrue("(InLove")) {....}
which leads to the script that makes that sprite follow the player.
But I keep getting isdebugbuild exceptions and the program crashes. The actual compiler errors are:
UnityException: get_isDebugBuild is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'FollowLove' on game object 'Danni'.
See "Script Serialization" page in the Unity Manual for further details.
PixelCrushers.DialogueSystem.Lua.RunRaw (System.String luaCode, System.Boolean debug, System.Boolean allowExceptions) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:250)
PixelCrushers.DialogueSystem.Lua.Run (System.String luaCode, System.Boolean debug, System.Boolean allowExceptions) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:129)
PixelCrushers.DialogueSystem.Lua.Run (System.String luaCode, System.Boolean debug) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:139)
PixelCrushers.DialogueSystem.DialogueLua.InitializeChatMapperVariables () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/DB/DialogueLua.cs:119)
PixelCrushers.DialogueSystem.DialogueLua..cctor () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/DB/DialogueLua.cs:88)
Rethrow as TypeInitializationException: The type initializer for 'PixelCrushers.DialogueSystem.DialogueLua' threw an exception.
FollowLove..ctor () (at Assets/Scripts/FollowLove.cs:16)
Do you know what I am doing wrong here? I feel like it's probably something simple about how the C# script is talking to Lua, but I don't know what it is.