TExcelTAD
Home › Unity with C# › Essential Packages

Essential Packages

Most of Unity's features ship as packages, installed per project through the Package Manager (Window > Package Manager). Packages are versioned, can be updated or removed, and are listed in Packages/manifest.json, which you commit.

The Package Manager

  • Unity Registry: Unity's official packages. In Project: what you have. My Assets: Asset Store purchases. Built-in: engine modules you can disable to slim builds (e.g. Vehicles, Cloth).
  • + > Install package by name… takes a package id (com.unity.cinemachine), and Install package from git URL… takes a Git repository, for open-source packages hosted on GitHub.
  • Scoped registries (in Project Settings > Package Manager) add third-party registries such as OpenUPM.
  • The Samples tab of a package imports example scenes and scripts.

A manifest looks like this (versions are illustrative; let the Package Manager choose verified versions for your editor):

json
{
  "dependencies": {
    "com.unity.inputsystem": "1.11.2",
    "com.unity.cinemachine": "3.1.2",
    "com.unity.render-pipelines.universal": "17.0.4",
    "com.unity.ai.navigation": "2.0.6",
    "com.unity.addressables": "2.3.16",
    "com.unity.test-framework": "1.4.6",
    "com.unity.netcode.gameobjects": "2.2.0"
  }
}

Packages/packages-lock.json records the exact resolved versions of every dependency, like package-lock.json in npm. Commit both files.

The packages this course uses

Package Id What for
Input System com.unity.inputsystem actions, rebinding, gamepads, touch (lesson)
Cinemachine com.unity.cinemachine procedural cameras, blends, shake (lesson)
ProBuilder com.unity.probuilder modelling and greyboxing levels inside the editor (Tools > ProBuilder > ProBuilder Window)
TextMeshPro part of com.unity.ugui in Unity 6 high-quality text for uGUI (lesson)
Addressables com.unity.addressables on-demand loading, remote content (lesson)
AI Navigation com.unity.ai.navigation NavMesh Surface baking, agents, links (lesson)
Netcode for GameObjects com.unity.netcode.gameobjects multiplayer (lesson)
Test Framework com.unity.test-framework Edit/Play Mode tests (lesson)
Localization com.unity.localization string tables, localized assets, locale selection, smart strings

Other frequently installed packages: Memory Profiler, Profile Analyzer, Recorder (capture gameplay video), Splines, Timeline, Shader Graph, Visual Effect Graph, Burst/Collections/Entities, Newtonsoft Json, Multiplayer Play Mode.

Localization in practice

The Localization package keeps text in String Tables (one column per language) and swaps it at runtime:

csharp
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;

public class CoinLabel : MonoBehaviour
{
    [SerializeField] LocalizedString coinsText;     // pick table + key in the Inspector; e.g. "Coins: {0}"
    [SerializeField] TMPro.TMP_Text label;

    void OnEnable()
    {
        coinsText.Arguments = new object[] { 0 };
        coinsText.StringChanged += Show;               // fires now and again whenever the language changes
    }

    void OnDisable() => coinsText.StringChanged -= Show;

    void Show(string text) => label.text = text;

    public void SetCoins(int coins)
    {
        coinsText.Arguments[0] = coins;
        coinsText.RefreshString();
    }

    public void SetLocale(int index) =>
        LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[index];
}

Plan for localization early: text in code ("Game Over") is expensive to find later, and some languages need 30–40% more space than English.

How dependencies resolve: a model

Packages depend on other packages. When two packages need different versions of the same dependency, the Package Manager picks the highest requested version (unless your manifest pins one directly, which wins). The model resolves a small graph:

csharp · try it yourself
using System;
using System.Collections.Generic;
using System.Linq;

var manifest = new Dictionary<string, Version>
{
    ["com.unity.cinemachine"] = new(3, 1, 2),
    ["com.unity.netcode.gameobjects"] = new(2, 2, 0),
    ["com.unity.addressables"] = new(2, 3, 16),
};
var deps = new Dictionary<string, (string Id, Version V)[]>
{
    ["com.unity.cinemachine"] = new[] { ("com.unity.splines", new Version(2, 6, 0)) },
    ["com.unity.netcode.gameobjects"] = new[] { ("com.unity.transport", new Version(2, 3, 0)), ("com.unity.collections", new Version(2, 2, 1)) },
    ["com.unity.addressables"] = new[] { ("com.unity.scriptablebuildpipeline", new Version(2, 1, 4)), ("com.unity.collections", new Version(2, 4, 3)) },
    ["com.unity.transport"] = new[] { ("com.unity.collections", new Version(2, 2, 1)), ("com.unity.burst", new Version(1, 8, 12)) },
};

var resolved = new SortedDictionary<string, Version>(StringComparer.Ordinal);
var queue = new Queue<(string, Version, string)>(manifest.Select(kv => (kv.Key, kv.Value, "manifest")));
while (queue.Count > 0)
{
    var (id, v, from) = queue.Dequeue();
    if (resolved.TryGetValue(id, out var have))
    {
        if (manifest.ContainsKey(id) || have >= v) continue;     // manifest pins win; otherwise keep the highest
        Console.WriteLine(
quot;{id}: {have} -> {v} (needed by {from})"); } resolved[id] = v; if (deps.TryGetValue(id, out var children)) foreach (var (cid, cv) in children) queue.Enqueue((cid, cv, id)); } foreach (var (id, v) in resolved) Console.WriteLine(
quot;{(manifest.ContainsKey(id) ? "direct " : "indirect")} {id} {v}");
com.unity.collections: 2.2.1 -> 2.4.3 (needed by com.unity.addressables)
direct   com.unity.addressables 2.3.16
indirect com.unity.burst 1.8.12
direct   com.unity.cinemachine 3.1.2
indirect com.unity.collections 2.4.3
direct   com.unity.netcode.gameobjects 2.2.0
indirect com.unity.scriptablebuildpipeline 2.1.4
indirect com.unity.splines 2.6.0
indirect com.unity.transport 2.3.0

That's why updating one package can change another you never touched. Read the changelog of indirect updates too, and update packages on a branch.

Test yourself

Which files record a project's packages and their exact resolved versions?

  1. ProjectSettings/ProjectVersion.txt
  2. Packages/manifest.json and Packages/packages-lock.json
  3. Library/PackageCache only
  4. Assets/packages.xml

Two packages need com.unity.collections 2.2.1 and 2.4.3. Which version is installed (no direct pin)?

  1. 2.2.1
  2. 2.4.3
  3. Both
  4. Neither: error

Which package do you use for greyboxing levels directly in the editor?

  1. Cinemachine
  2. ProBuilder
  3. Addressables
  4. Localization