SetProgramVariable clobbers data types.
snail
SetProgramVariable changes the type of the variable you're setting to object, regardless of the original type or the value being passed in.
Photo Viewer
View photos in a modal
Log In
Μerlin
Many externs are capable of screwing with the data type on a variable,
SetProgramVariable
is one of the most easily reproducible ones though. GetProgramVariableType
is the bigger issue, it gives you the strongbox type of a variable. Which is not guaranteed to stay the same during program execution, and it quite likely to get changed in many cases since the VM will reassign strongbox types to make things work. In many cases just copying a variable is enough to change the target variable's reported type. For GetProgramVariableType
to work as expected in a statically typed language it should only return the original strongbox type set on a variable.Side note: GetComponent(s)<T> apparently uses (or used, I'm not sure if it has been fixed)
GetProgramVariableType
internally which causes GetComponent(s)<T> to break when you're calling it on a variable that has been altered from its expected type of Component
to System.Object
.