Game Optimization techniques inside Unity

It is the desire of every Game Developer to achieve good quality and develop a highly optimized game. In this article, I'll be sharing some techniques which every game developer should consider while developing a Game. These techniques will not only optimize your game but will also improve the quality of your game.

  1. Entity Component System (ECS): Unity has launched the Data-driven programming with the new Entity Component System. The benefits you can get from this new system are undeniable, If you utilize the ECS properly you can get highly optimized results.
  2. Data-Oriented Tech Stack (DOTS): Unity can now fully utilize the parallel processing through Unity’s Data-Oriented Tech Stack (DOTS), Job systems, and Burst compiler. The Job system and Burst compiler can give you an unbelievable rise in FPS.
  3. Universal Render Pipeline (URP): The Basic shaders (standard, legacy, etc ) vs Universal Render Pipeline(URP), URP can improve the FPS by 50%. These are highly optimized shaders and the game quality will also get much better if you use URP instead of Basic shaders.
  4. Scriptable Objects: Scriptable Objects is the best technique for storing data, Instead of using Monobehaviour classes for storing data try to use scriptable objects. These are considered as the best data containers
  5. Actions and Callbacks: Instead of using conditional statements inside update and waiting for an event to occur, or accessing functions of other scripts by declaring it static or accessing it by an object reference, a single solution for all these issues is to use actions and callbacks. Unity has two types of implementation for this, you can either use directive Action or events and delegates, Both of these implementations are the same but using is the shortcut way of doing this.
  6. Threads vs Coroutines: Coroutines use sequential processing and only one coroutine is executing at any given time. Threads are mostly used for utilizing parallel processing. Since nowadays almost all the devices have multiple cores and to utilize these cores it is best to use Threads instead of Coroutines.
  7. Abstract Classes and Interfaces: These two things are better for the organization of your code since abstract classes can't be instantiated so better to keep the basic properties in the base abstract class and declare the remaining attributes in the child class. If you want to have a good architecture and properly organized code you cannot avoid the use of interfaces.
  8. Occlusion Culling: Occlusion culling is the technique where you can hide 3D objects which are not rendering in the current frame. So this can highly improve the FPS.
  9. Update, FixedUpdate, LateUpdate: Extensive use of these three functions can cause a huge drop in FPS, avoid the use of these functions as much as possible. Although some times it is not possible to avoid these functions, so in that case try to use the proper functions, for example, physics-based code should be written inside FixedUpdate because this is frame independent, Calculations related to the current rendering camera should be done inside LateUpdate because this callback executes after completing the current frame rendering process.
  10. Baking shadows: It is best to bake shadows of static objects although it will increase the build size, But you can get much better FPS.
  11. Static Batching: Static batching can reduce the draw-calls and can highly improve the FPS.
  12. Combined Meshes: It is better to use combined meshes rather than multiple meshes, so if you have a 3D environment try to use the minimum number of meshes.
Muhammad Saad Salman

CEO at Minor Bugs - A Gaming Lab | Love to discuss Ideas | Open to New Ventures

4 年
回复
Abdul Arsalan

Shopify Developer

4 年

Very useful

Imran Ali Chaudry

Product Manager at Hazel Mobile

4 年

Thanks for posting

回复
Ihsan Ali

Unity Game Developer | Research Scholar | Learning Ai & Ml | Freelancer

4 年

Thanks for sharing such useful tips sir.

要查看或添加评论,请登录

Hameed Ullah Jan的更多文章

社区洞察

其他会员也浏览了