I was reading through this : Unity - Scripting API: Object and it seems that “objects” don’t exactly work the same as “gameObject”, in that it is never explicitly typed out like gameObject.
With gameObject, you can type something like: gameObject.camera
But with object, instead of typing Objects.FindObjectsOfType(HingeJoint), you just simply type FIndObjectsOfType(HingeJoint). Or instead of typing Object.Instantiate(…), you simply type Instantiate(…).
I also tried to explicitly type out objects in MonoDevelop and an error tells me: Unknow identifier ‘objects’/‘Objects’.
So I’m a bit confused… why is ‘object’ allowing for this kind of omission? Is it a concept that is different to gameObject?
object (lowercase o ) is the base class for all .Net (C#) classes. It’s the furtherest down you can go. Anything in .NET can be downcast to it.
Object (uppercase o) is Unity’s base class. Everything you see in Unity project ie. Folders, Scenes, Scripts, sprites, music, etc are of base class Object. This becomes very important when doing editor scripting.
If you know about Polymorphism the base type Object becomes very useful for generic programming. If you don’t know about it I would suggest reading up as it’s a staple of OOP.
Object is the base class of all objects unity can reference. If you look through the documentation for other elements, under the name you will see something like Namespace: Inherits from: [Class]. It may not always be Object but if you keep clicking the names you will (in not all but many cases) eventually arrive at Object.
The reason for this is simple, and what inheritance is in part for, it gives all the children a set of common variables and behaviours. Which allows the code to aggregate objects under a base type and use the common elements. In most cases you will probably not want to go as deep as Object.
GameObject inherits directly from Object and specialises it to represent objects that can be used in Unity scenes. Therefore it has access to (public and protected) members of Object.
But Object and GameObject are not equal.
Also within a MonoBehaviour you can use Instantiate or FindObjectsOfType without referring to anything, because MonoBehaviour inherits from Object (therefore you own script that inherits from MonoBehaviour also inherits from Object.