Whats the difference between public and static variable?

As question says whats the difference?

static - the same variable is shared by all instances of the class that are created, and can be private, protected or public.

public - a seperate variable for each instance of the class, and it is visible and accessible from outside of the class.

As i undertand it :

  • a public variable will be accessible by other scripts
  • a private variable will not be accessible by other scripts

public & private var are unique for a script instance.

  • a static variable will be shared betwenn all the instances of your script.

For more details : http://answers.unity3d.com/questions/47565/public-private-and-static-variables-in-js