Quantcast
Channel: Answers by "AyAMrau"
Viewing all articles
Browse latest Browse all 91

Answer by AyAMrau

$
0
0
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.

Viewing all articles
Browse latest Browse all 91

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>