Unity Architecture
Unity Architecture
Unity Architecture
• The Unity engine is built with native C/C++ internally, however it has a C#
wrapper that you use to interact with it. As such, you need to be familiar with
some of the key concepts of scripting in C#.
2
HOW DOES UNITY USE .NET ACTUALLY?
The .NET platform is a free and open-source, managed
computer software framework for Windows, Linux, and
macOS operating systems.
The project is mainly developed by Microsoft employees
by way of the .NET Foundation and is released under an
MIT License.
3
THE SCRIPTING
BACKENDS IN UNITY
Unity has two scripting backends:
Mono and IL2CPP which is the
intermediate language To C++,
each of which uses a different
compilation technique:
Mono uses just-in-time (JIT)
compilation and compiles code on
demand at runtime.
IL2CPP uses ahead-of-time (AOT)
compilation and compiles your
entire application before it is run.
4
Code reloading in the Unity Editor 5
When you enter Play Mode, your project starts and runs as it would in a build. Any changes you make in the Editor
during Play Mode reset when you exit Play Mode.
When you enter Play Mode in the Editor, Unity performs two significant actions to ensure your project starts in the Editor
in the same way as it would in a build:
These two actions take some time to perform, and the amount of time increases as your scripts
and Scenes become more complex.
The ability to quickly enter and exit Play Mode is an important factor while you are developing your game or app. The
faster you can enter and exit Play Mode, the faster you can make and test changes.
Because a rapid speed of iteration while developing is important, and because the time to reset the Scene and scripting
state can become an obstacle to that, Unity offers the ability to configure what happens when you enter Play Mode,
giving you the option to disable either, or both, of the “Domain Reload” and “Scene Reload” actions. These two options
are provided by the Configurable Enter Play Mode feature.
The diagram below shows the effects of disabling the Reload Domain and Reload Scene settings.
6
SCRIPT SERIALIZATION AND COMPILATION
SERIALIZATION COMPILATION
• Serialization is the automatic process of • By default, Unity compiles almost all of your game scripts into
transforming data structures or GameObject the predefined assembly, Assembly-CSharp.dll. (Unity also
states into a format that Unity can store and creates a few smaller, specialized predefined assemblies.)
reconstruct later. • This arrangement works acceptably for small projects, but has
• How you organize data in your Unity project some drawbacks as you add more code to your project:
affects how Unity serializes that data, which can • Every time you change one script, Unity has to recompile all
have a significant impact on the performance of the other scripts, increasing overall compilation time for
your project. iterative code changes.
• Any script can directly access types defined in any other script,
which can make it more difficult to refactor and improve your
7 •
code.