Unity: basics, architecture and C# development

Author: IT Sectr Published: 2026-05-02 Reading time: 9 min

Unity is a cross-platform game engine for creating 2D and 3D applications with support for building on mobile platforms, desktop and consoles. It is used both for game development and for non-gaming applications in architecture, automotive and retail. According to Unity Technologies, 2025, over 70% of mobile games in the App Store top 1000 are built with Unity. C# is the engine’s primary programming language used to write game logic, components and editor scripts.

Key Takeaways

  • Unity — a cross-platform game engine supporting 2D, 3D, AR and VR
  • C# — the primary language for writing game logic, components and editor scripts
  • Component architecture — object behavior is built from components (MonoBehaviour)
  • Asset Store — a marketplace with ready-made models, textures, sounds and plugins
  • Mobile build — builds for iOS and Android optimized for ARM architecture

What is Unity?

Unity is a game and real-time application development environment created by Unity Technologies in 2005. The engine supports 27 platforms including iOS, Android, Windows, macOS, PlayStation, Xbox, Nintendo Switch and WebGL. According to the Unity Gaming Report (2024), over 3 billion mobile games were launched monthly on Unity in 2023.

The key feature of Unity is its component-oriented architecture. Each object in the scene is an empty container (GameObject) to which components defining its behavior are added: rendering, physics, sound, animation and custom logic. This distinguishes Unity from hierarchical engines like Unreal Engine, where behavior is defined through class inheritance.

According to Statista (2025), Unity holds 48% of the game engine market for mobile games, surpassing Unreal Engine (15%) and proprietary solutions (37%). The engine is chosen by indie studios for its low entry barrier and by major publishers for the flexibility of its build pipeline across different platforms.

Unity architecture: scenes, objects and components

Unity’s architecture is built on four fundamental concepts: scenes, GameObjects, components and prefabs. Understanding this hierarchy is essential for working effectively with the engine.

Scenes and GameObjects

A Scene is a container that holds all the objects for a game level or application state. Each scene has its own set of GameObjects, lights, cameras and audio sources. Switching between scenes is done via SceneManager.LoadScene().

A GameObject is the basic building block of Unity. It has no visual representation or default behavior — it is an empty node in the scene hierarchy. All behavior and appearance are added through components. For example, to make a GameObject visible, you add a MeshRenderer; to make it follow physics, you add a Rigidbody.

MonoBehaviour components

MonoBehaviour is the base class for all custom scripts in Unity. It provides a lifecycle: Awake (called when the object is loaded), Start (before the first frame), Update (every frame), FixedUpdate (every physics step) and OnDestroy (when destroyed).

Each component can interact with other components on the same GameObject through GetComponent<T>(). This enables modular systems: for example, a Health component can be independent of a Movement component, yet both can respond to events via UnityEvent.

Prefabs

A Prefab is a GameObject template saved as an asset in the project. Changes to the prefab automatically apply to all its instances across scenes. This is the central reuse mechanism in Unity, speeding up iterations and reducing errors.

Prefabs support nesting (Nested Prefabs): a prefab can contain other prefabs, forming a hierarchy. For example, a car prefab can contain wheel, engine and body prefabs, each with their own components and settings.

C# code examples in Unity

Let’s look at a basic character movement component in C#. This script moves an object forward relative to its current rotation and handles user input.

csharp
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public float speed = 5f;

    void Update()
    {
        float move = Input.GetAxis("Vertical");
        Vector3 direction = transform.forward * move;
        CharacterController controller = GetComponent<CharacterController>();
        controller.SimpleMove(direction * speed);
    }
}

The Update() method is called every frame. Input.GetAxis reads vertical input, SimpleMove applies movement with physics. CharacterController is a built-in Unity component that handles collisions without writing custom collision physics.

An example script for handling collisions and applying damage:

csharp
using UnityEngine;

public class DamageHandler : MonoBehaviour
{
    public int health = 100;

    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Enemy"))
        {
            health -= 10;
            if (health <= 0)
            {
                Destroy(gameObject);
            }
        }
    }
}

The OnCollisionEnter method is called by the physics engine when a GameObject collides with another object. Tag comparison (CompareTag) determines what the collision was with. This approach enables reusing the DamageHandler component for the player, enemies and destructible objects without changing the code.

Mobile game development with Unity

Unity provides specialized tools for optimizing games for resource-constrained mobile devices. Key optimization areas include memory management, reducing draw calls and adapting to various screen resolutions.

Performance optimization

For mobile platforms, Unity offers Asset Bundles — a content packaging system that loads resources on demand, reducing the initial app size. This is especially important for games with many levels or characters where loading all assets at once is impossible due to app store limits.

The Unity Profiler allows analyzing CPU, GPU and memory usage on real devices via ADB (Android) or USB (iOS). According to Unity Documentation (2025), optimizing draw calls to 100–300 on mobile devices delivers stable 60 FPS on mid-range devices.

Touch input and UI

For mobile games, Unity uses the Input System, which abstracts touch controls, accelerometer and gyroscope under a unified API. Virtual joysticks, swipes and taps are configured through Input Action Assets without writing touch handling code.

Unity’s UI system (uGUI) supports Canvas Scaler for automatic interface adaptation across different screen aspect ratios. The Canvas Scaler component with Scale With Screen Size mode ensures buttons do not go off-screen on tablets and smartphones.

Building for iOS and Android

Building mobile games in Unity is done through the Build Settings window. Android requires Android SDK and NDK; Unity generates a Gradle project that compiles into APK or AAB. iOS requires Xcode — Unity creates an Xcode project with an Objective-C/Swift wrapper that is finally compiled through Apple.

IL2CPP is a compilation option that translates C# code into C++ and then into native ARM code. According to Unity Benchmark (2024), IL2CPP increases performance by 15–25% on iOS and Android compared to Mono, but increases build time and binary size.

Unity vs other engines

Unity is often compared to Unreal Engine and Godot as the main alternatives in the game engine market. The choice depends on the project type, team expertise and target platforms.

CriteriaUnityUnreal Engine 5Godot 4
LanguageC#C++ / BlueprintsGDScript / C#
GraphicsBuilt-in / URP / HDRPNanite + LumenCustom renderer
Mobile optimizationExcellent (70% of mobile games)Good (AAA porting)Good (lightweight engine)
Entry barrierLowHighLow
LicensePersonal / Pro / Enterprise5% royalty (up to $1M)MIT (free)

For mobile games, Unity remains the industry standard thanks to its flexible rendering system (URP — Universal Render Pipeline), which optimizes graphics for mobile GPUs with limited compute power. URP automatically reduces the number of rendering passes and batches shaders to lower GPU load.

Unreal Engine 5 offers the best graphics quality (Nanite for geometry, Lumen for lighting) but requires more powerful hardware and greater team expertise. Godot attracts with its open source code and small engine size but has fewer ready-made assets and a smaller talent pool.

Unity for non-gaming applications

Unity is actively used beyond game development — in architecture, automotive, retail and education. Real-time 3D visualization (RT3D) allows creating interactive 3D presentations, simulators and product configurators.

In the automotive industry, Unity is used to create digital twins of cars and HMI (Human-Machine Interface) systems. Mercedes-Benz and BMW use Unity for prototyping dashboard displays and multimedia systems before a physical prototype is built.

In retail, Unity is used for product configurators: IKEA (virtual furniture placement), Nike (sneaker customization) and Audi (car configurator) — all built on Unity. Users can change colors, materials and options in real time and see the result in 3D.

For non-gaming projects, Unity provides specialized tools: AR Foundation (for ARKit and ARCore), Pixyz Plugin (for CAD model import) and Unity Reflect (for synchronization with Revit BIM models). The company is actively developing the Unity Industry direction, which includes cloud services for enterprise clients.

Frequently Asked Questions

Is it difficult for a beginner to learn Unity?

Unity is considered one of the most accessible game engines for beginners thanks to extensive documentation, free Unity Learn courses and a huge community. To get started, you need to know the basics of C# and understand the principles of component architecture. Most beginners create their first game within 2–3 months.

Can you create 2D games in Unity?

Yes, Unity has a full 2D pipeline: Sprite Renderer, 2D Physics (Box2D), Tilemap for creating levels from tiles and 2D Animation for skeletal sprite animation. Many popular 2D games, including Hollow Knight and Cuphead, were created in Unity. 2D tools are built into the engine without needing to install plugins.

How much does Unity cost for mobile development?

Unity Personal is free with annual revenue up to $200,000. Unity Pro costs $2,040 per year per developer and includes advanced profiling tools, cloud build and priority support. For mobile development, the Personal tier is sufficient for most indie projects.

How is Unity different from the Cocos2d game engine?

Cocos2d is a 2D framework with support for C++, Lua and JavaScript, focused on simple 2D games. Unity is a full-featured 3D/2D engine with an editor, visual tools and support for 27 platforms. Cocos2d is popular in Asia for hypercasual games, while Unity is a universal choice for any genre.

Does Unity support AR and VR?

Yes, Unity has built-in support for AR and VR through AR Foundation (ARKit + ARCore), XR Interaction Toolkit and OpenXR. VR projects like Half-Life: Alyx (tech demo) and VRChat were created with Unity. The engine supports all major VR headsets: Meta Quest, HTC Vive, Valve Index and PlayStation VR.

Summary

  • Unity — a cross-platform engine for 2D/3D games and real-time applications in C#
  • Architecture is built on scenes, GameObjects, MonoBehaviour components and prefabs
  • C# — the only language for game logic, components and editor extensions
  • Mobile optimization — IL2CPP, Asset Bundles, URP and Profiler for iOS and Android
  • Comparison — Unity leads in mobile (48%), Unreal in AAA, Godot in indie
  • Non-gaming use — architecture, automotive, retail and interactive 3D presentations
  • Entry barrier — low, with free Unity Learn courses and a huge community

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also