Wondering what behind unity components.

Hello ,

I’m wondering what stands behind unity components (C#)

I’m asking this question in order to improve my understanding in C#.

As I understand GameObject is the main class.

How all the other components attached to the GameObject in console is implemented in the GameObject?

for example.
Transform ,
Our scripts,

Thank you in advance.

I believe this is mostly about a basic understanding for how it works in the background, and less about involved optimizations. If so, imagine it like this: Unity has a list of GameObjects in your scene. Each GameObject can have a list of components. Each component follows this lifecycle:
So after the initial Awake(), Start(), OnEnable(), .. functions have been called for a script, the rest of the functionality is handled at specific timesteps. When a frame is completed and the next one starts, Unity goes through all available active GameObjects and all of their available active components and calls the Update() function there. The same happens at a fixed timestep for FixedUpdate and so on.
'Events' like activating a deactivated component or GameObject are handled through the corresponding function calls or property accesses, which then queue these actions until the correct moment in the execution order i linked above. So for example, destroying an object happens after the current frame is completed, activating an object happens at the beginning (before) the next frame and so on. The specific order of all involved functions can again be seen in the link above.

Transforms are a bit special and every GameObject must have one, so it's handled as a property of GameObject: https://docs.unity3d.com/ScriptReference/GameObject.html

This is of course a simplified view and abstracts from most of the optimizations done in the background, but for getting an idea of how things are connected it should be close enough. Hope this answers some of your questions. It's mostly an architectural question tho, and wont really improve anything related to C# knowledge^^

Hi ,

Thank you very much for your answer