Page 2 of 2

Re: UI Bar connected to Variables

Posted: Sat May 25, 2024 6:35 am
by Albyd
It doesn't show and after interacting with an NPC who should increase the value, this is the error i'm getting:

InvalidCastException: Specified cast is not valid.
Confidence_bar.OnVariableChanged (System.String variableName, System.Object variableValue) (at Assets/Confidence_bar.cs:21)
Language.Lua.Assignment.SetKeyValue (Language.Lua.LuaValue baseValue, Language.Lua.LuaValue key, Language.Lua.LuaValue value) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Interpreter/Chunk/Assignment.cs:133)

Re: UI Bar connected to Variables

Posted: Sat May 25, 2024 9:16 am
by Tony Li
Are you using the second version of the method with the Debug.Log line? It should show something. Since it reports line 21, I suspect it's not using the second version. Try this:

Code: Select all

void OnVariableChanged(string variableName, object variableValue)
{
    Debug.Log($"{variableName} changed to {variableValue}");
    if (variableName == "Confidence") scoreSlider.value = (float)((double)variableValue);
}