When i was typing my code i wanted to add are variable but when i typed var it changed to SerializePrivateVariables. And there wasnt var!!! can anyone tell me how you write a variable in the new unity update? because it always changes to SerializePrivateVariables.
The var keyword only works inside of a method, not at the class level. There’s really not a reason to use the var keyword at the class level that I can think of considering you can just declare everything without the need of dynamically allocating the value; However you can use the var keyword inside of a method.
public class Test : Monobehaviour {
// This will cause an error, because it's in the class scope.
var myInt = 5;
void Start() {
// This will not cause an error, because it's in the method scope.
var myInt2 = 5;
}
}