static classes

I’ve seen examples of classes that are used as static but don’t the keyword static preceding in the script title

public class SomeScript
{
      static someVariable;
}

but I’ve also seen it where the class is labeled as static

public static class SomeScript

and both are accessed the same way. What’s the difference and when you should you use one over the other? Thanks.

Don’t think of static as an easy access modifier. Static rather makes your variable unique. If something is static it means that you only have one of it at all times. You are unable to produce any instances of it.

Bad example: Lets say you have an enemy script with a health variable. If you would make the health varible static, then every enemy in your scene would die simultaniously since they share the same health.

Good example: You have a class settings with the variable volume. If you make the variable volume static, then you can modify and read the volume variable without worrying about getting the right instance. Such a settings class is a good candidate for a static class since you want to access it easily from everywhere and you don’t want to have multiple instances of it at all times.

Here is some documentation on that.