- Home /
How unity works under the hood?
Hello guys, so i just cant wrap my head around how unity does some things. So first of i have studied a little bit the base classes in unity through visual studio and i came up with this family tree; it shows what classes are derived from what other classes and so on. so my first question is: when a scene is loaded in unity the objects in that scene are instantiated right, so what is the class that the instance of that game object is created from. is it Object or GameObject base class ? My second question is: i understood that the components of a game object are also instances of classes; for example Rigidbody component in the inspector is a instance of the RigidBody class. Now , i have seen that in the base class "Component" there are some properties of type Component, which contain a get; now that property returns a object of type Component, which i feel is useless because anyway in my scrips i cant use that property to access different features of the component due to it not being of the type of the Transform,Rigidbody etc. So why are there those propertys in the Component class having the name of the components but are not of the type of the components?. Now my biggest confusion come from this: How does the GetComponent(); work, how does it connect and get hold of the actual instance of the Transform component; because if my family tree is correct my script does not inherit from Transform or RigidBody classes. Also there has to be a reason for those Component instances in the Component base class and the individual classes for the components themselves. i Would just like a answer which clarifies everything and explains me how everything works and links together in my family Tree below. Thank You in advance, it means a lot to me if you could explain! ps: @FireStone720 I have seen you have answered some of these questions, do you mind if you give a read my question and say what is on your mind :) Any help from anyone will be very appreciated :)
Your answer
Follow this Question
Related Questions
Composition: Multiple actions on death 1 Answer
Classes and Scripting 2 Answers
Inheritance and Component Types in C# 2 Answers
Class inheriting Runtime Classes 1 Answer