Open
Description
[CASE]
0. Declare Variable First
uint value = 1;
-
The variable type is unit at this point.
-
Assign a value to it
value = 10; -
Now the type of 'value' is int (as engine evaluates 1 as int)
-
Variable type changed.
[Solution]
Change AssignVariable method:
if (Variables.ContainsKey(varName) && Variables[varName] is StronglyTypedVariable stronglyTypedVariable)
{
...
}
else
{
try
{
if (Variables[varName].GetType() == value.GetType())
{
Variables[varName] = value;
}
else
{
Variables[varName] = Convert.ChangeType(value, Variables[varName].GetType());
}
}
catch (Exception exception)
{
throw new InvalidCastException(exception.Message, exception);
}
}