Hi,
Do you know constructors? They are special methods that create objects for us. It requires the new
keyword. If we wrote pure C# code, we would use new
and constructors “everywhere” with one exception: For the primitive types in C#, you do not need any constructor. Float is a primitive type.
However, we do not write pure C# code. Instead, we use Unity classes. Unity wants to create its own objects. For this reason, you basically never see something like Player player = new Player();
in Unity code. The Player class, in this case, inherits from MonoBehaviour, which is a Unity class.
One more thing: Note that I explicitely wrote about Unity classes. Classes are so-called reference types because we don’t work with objects directly but reference them. In C#, there are also structs and enums, which are value types. Vector3 and Color32 are structs. We know that from the API (and from our script editor). We may call constructors to create a new struct object.
If you find this confusing, the best way to learn this is to simply memorise the C# value types. That list is short. Everything else is a reference type. And then you only have to know if the reference type is a Unity type or “another” type. Of course, you don’t have to know all Unity and C# classes by heart. There are several tens of thousands. Your script editor will tell you if something is a Unity class or not.
Did this clear it up for you?
See also: