Cherchez Unity

Set up a smart game development pipeline

Last updated: January 2020

What you will get from this page: A guide to reference throughout your game development cycle. Follow these tips from Unity field engineer Valentin Simonov to set up a smart development pipeline and ultimately ship better and more performant content.

Plan & research your game project

The most important part of any software development project: decisions made in this phase set the course for your entire development cycle.

Map features to target platforms

  • Check that all planned features work on all target platforms. This is especially relevant for WebGL, which has some constraints regarding memory management, multithreading, networking and plugin support.

Specify the minimally supported devices for your project

  • Rendez-les disponibles pour vos équipes de développement et de QA.
  • Test early and throughout development to maintain a realistic performance and frame budget.

Set frame and asset budgets early on

Vous devez définir des budgets pour :

  • Models — how many vertices is the target device able to render?
  • Assets — how detailed should models and textures be?
  • Scripts and rendering — what % of the frame do you have for logic, rendering, Effects and other subsystems?

Plus d'astuces :

Optimiser les performances des graphismes
Modéliser des personnages pour des performances optimisées

Set Scene and prefab decomposition early on

  • Diviser les niveaux (activement chargés) en scènes.
  • Move separate objects into Prefabs. Nested Prefabs further increase scene decomposition and reduce merge conflicts.
  • S'accorder sur le mécanisme de verrouillage de la scène principale.

Plan your asset pipeline process

The import process needs to accommodate artists’ specs for assets.

  • Si possible, faites appel à un artiste technique dès le début pour définir ce processus.
  • Définir des directives claires sur les formats et les spécifications des ressources.
  • Use Asset Postprocessors to automate asset importing.

Plus d'astuces :

Guide des bonnes pratiques en matière de ressources artistiques
The new asset import pipeline in Unity
Nested Prefabs

Unity Asset importing

Line up your Build and QA process

  • Set up a build machine, or, turn on and set up Unity Teams.
  • Establish a process for:
    • Publishing features to the release build
    • Testing new builds
    • Automating tests
    • Recording statistics

Unity setup Cloud Build

Prototype ideas, but prepare to start actual project from scratch

After building a prototype and getting it approved by the management, strongly consider starting it from scratch.

  • Les décisions prises pendant la phase de prototypage permettent généralement de progresser plus rapidement.
  • Baser votre jeu sur un ensemble de hacks n'est pas un point de départ idéal.


Speed up development

Follow these best practices to speed up development and boost the quality of the final product.

Set up correct version control

  • Utiliser la sérialisation de texte (par défaut dans Unity).
  • Set up built-in YAML merge tool. See more about SmartMerge here.
  • Set up commit hooks. See more ici.

Use the Cache Server

  • Changer de plateforme affecte la vitesse du développement.
  • Make sure to set up the Cache Server for your team.

Avoid storing static data in JSON or XML files

  • Le chargement s'en trouve ralenti.
  • L'analyse génère des déchets.
  • Instead, for built-in static data use ScriptableObjects with custom editor tools.

Don’t leave unused assets, plugins and duplicated libraries in your project

Unused assets in your project can still be built into the game. Make sure that you don’t leave garbage in your project: if you set up a version control system, restoring files should be easy.

  • Check what dependencies assets from the Asset Store drag into the project. For example, you might be surprised to find that you have five different JSON libraries in the project.
  • Check for outdated assets and scripts from early prototypes.
  • Moving old assets to the “removed” folder still results in resources and scripts being built into the game.

Les actions répétitives requièrent une intervention manuelle.

  • Un script d'automatisation doit être associé à chaque tâche répétitive.
  • Make sure that you can “play” the game or interactive content from any scene.
  • Consider a solution, such as Cloud Build, that automates the build process.

Plus d'astuces :

How to set up a stable and flexible build pipeline

Profile your project on target devices as well as in the editor

  • Always profile the content on your target device; if you profile in the editor only, you can miss performance bottlenecks.

Profiler Unity

Use both built-in and platform-specific profiling and debugging tools

Here are resources to learn about Unity’s profiling tools:

Profile and optimize early on

  • Plus vous attendez pour profiler, plus les coûts en matière de performances augmentent.
  • Commencez le profilage suffisamment tôt pour vous assurer que votre projet correspond au cadre et aux budgets en matière de mémoire et de taille de disque.
  • Profile before your optimize, so that you have the data you need to optimize actual bottlenecks.

Make sure you know as much as possible about your target platform(s)

  • Les plateformes bureau, mobile et console présentent des goulots d'étranglement différents.

Unity best practices development

Choose the correct Asset settings

Assets take up most of the size of your game. Save time on optimizing by thinking carefully about Asset settings.

Set up Sprite Atlases correctly

  • Make sure that you use Sprite Atlases for sprites used together in a scene. This will reduce the number of draw calls in the game/interactive content.
  • Or, consider using Tilemap, which can improve performance of 2D games. Get some tips for optimizing with Tilemaps ici.

Set up texture settings correctly

  • Vous devez connaître les paramètres de textures appropriés pour la plateforme cible :
    • Quelle compression la plateforme supporte-t-elle ?
    • Les textures requièrent-elles des mipmaps ?
  • Set up an automated way to apply these settings for new textures using l'API AssetPostprocessor as shown by ce projet.
  • Empêcher les artistes d'utiliser des textures aux paramètres inappropriés.

Unity Asset import settings

Try the Addressable Asset System

The new Addressable Asset System provides a framework to solve a set of common problems related to addressing, building, and loading assets. It handles asset management overhead by simplifying content pack creation and deployment. Try these resources for more information:

From the Blog: Addressable Asset System
From the Docs: Addressable Asset System docs
From Unite: Addressables for live content management

Unity best practices asset settings

Boost programming productivity

Boost productivity with best practices for code architecture.

Know how to use your code editor efficiently

  • Make sure to know all the features and shortcuts of your code editor as it can speed up everyday tasks.
  • If you use Visual Studio, see this video on tips and tricks when working with a Unity project. Or, watch this video for tips on JetBrains Rider.

Avoid abstract code

  • Abstract Enterprise code is rarely justified because it runs slowly and requires IL2CPP to generate more code.

Establish and document clear architectural conventions:

  • When writing code, don’t use different methods to accomplish the same task, e.g.
    • Formats de configuration (fichiers, propriétés, ressources).
    • Évènements (évènements Unity, évènements C#, SendMessage).
  • Define which manager is responsible for which objects?

Understand the Unity frame loop

  • Quand Awake, OnEnable, Update et d'autres méthodes sont appelées.
  • Quand les coroutines sont actualisées.
  • Comment FixedUpdate est exécuté.

Avoid relying on Unity execution order for script initialization logic

  • When a MonoBehaviour is instantiated during the game Unity calls its Awake and Start methods. While the game is simple enough the order in which MonoBehaviours are initialized when the first scene is loaded might not matter. Later you might want to change this order using the Script Execution Order list in Project Settings. But once you have more than a few scripts in this list, relying on it can make it a source of hard-to- track bugs. In this case you should create a script which calls initialization functions for all your other MonoBehaviours at startup.

Account for framerate when scripting logic or animation

  • Utilisez Time.deltaTime pour les scripts indépendants FPS.

Plus d'astuces :

3 ways to architect with Scriptable Objects
Pour une expérience de programmation plus agréable

Unity best practices programming

Optimize CPU Performance

Optimize CPU usage for smooth performance and a longer battery life.

Unity CPU Profiler

Use Update() method sparingly

  • Native -> Managed calls have some overhead. Use custom managers instead
  • Avoid having custom Behaviours inherit from an abstract class with Update/Awake/Start methods defined

Define how frequently you need to update different systems in your game

Not all systems need to be updated every frame. Areas to look at include:

  • Déplacement d'objets.
  • AI and pathfinding.
  • Connexion et sauvegarde de l'état du jeu.
  • Other "heavy" systems.

Cache data you need frequently, such as:

  • Reflection
  • Find()
  • Camera.main
  • GetComponent()

Pool frequently instantiated objects

  • Instancier des objets est un processus lent.
  • Create pools of objects at the start of the game/content.
  • Réutilisez des objets au lieu d'en créer de nouveaux.

Don’t allocate memory for every frame

  • Small allocations every frame will cause a GC spike.
  • Essayez d'éliminer TOUTES les allocations.

Try alternatives to memory-allocating APIs, such as:

  • LINQ.
  • Concaténation de chaîne
  • Matrices retour de l'API Unity :
    • Physics.RaycastAll, Mesh.vertices, GetComponents, etc.

Plus d'astuces :

1K update calls
Unity’s evolving best practices

Unity best practices CPU performance

Optimize GPU Performance

Avoid spikes in graphics performance with these tips.

Unity GPU Profiler

Avoid overdraw in mobile games because it causes performance bottlenecks

  • Les GPU mobiles peuvent appeler un nombre de pixels maximum par seconde.
  • N’appelez pas d'images transparentes inutiles.
  • Utilisez plus de maillages complexes pour les espaces entièrement transparents.

Use the Universal Render Pipeline for your shaders in mobile projects

Watch for incorrect settings that can break dynamic batching

  • Les objets doivent être similaires pour être traités par lots de manière dynamique.
  • The Frame Debugger shows why certain objects were not batched.
  • Use the SRP Batcher with the Universal Render Pipeline to increase the number of batched objects.

Set up LODs correctly

  • LODs enable economic rendering of objects further from the camera.

Plus d'astuces :

Pourquoi vos requêtes ne sont-elles pas traitées par lots ?
Bonnes pratiques en matière d'optimisation mobile

Unity best practices GPU performance

Optimize UI Performance

Unity UI is an artist-friendly tool. Follow these tips to keep your UIs performant.

Unity UI

Account for different resolutions and aspect ratios

  • Testez l'IU sur des appareils avec différentes résolutions et ratios d'aspect.
  • Parfois, mieux vaut créer différents écrans d'IU pour différents appareils.

Déplacez les éléments animés vers des toiles séparées.

  • The Canvas creates a new combined mesh when an element changes, which can be costly for complex Canvases.

Avoid lag when a new UI window is opened

Your game experiences lag when a new window or a big chunk of UI is created. Minimize this effect by:

  • Making UI windows less complex.
  • Splitting UI in parts.
  • Caching windows.

Make sure your lists don’t contain a large amount of items

  • Réutilisez dynamiquement les éléments de la liste au lieu de les créer.
  • Créez une toile imbriquée dans la liste.
  • Use open source implementations, such as ce.

Voir :

Conseils d'optimisation d'IU Unity

Unity best practices UI performance

Dites-nous si vous avez aimé ce contenu !

Oui, continuez comme ça Ça pourrait être mieux

Ce site utilise des cookies dans le but de vous offrir la meilleure expérience possible. Consultez la page de politique des cookies pour en savoir plus.