ME FIRST GAMES
Menu
games for me and you
![]() Here are some super basic tips to increase your game's performance in Unity 📌 Only run code when things change. Instead of constantly polling and checking a state inside Update, try using Events and Actions to trigger code when something changes. 📌 If polling is required, then try only running your code every N frames or after a delay. Your AI code probably does not need to fire every frame. 📌 Move code out of loops when they can be run once, before, or after. 📌 Cache references and values instead of calculating them every time. GetComponent is included. 📌 Pool objects instead of Instantiating everything. Keep GameObjects in a list and when they are no longer needed, disable them. Enable them later as needed. 📌 Never use SendMessage and Camera.main. They are slow. 📌 Do not use FindObjectOfType. Instead, serialize a reference and link it in the Editor. Alternatively, you can create a singleton and use the reference directly. 📌 Avoid Vector3.Distance and Vector2.Magnitude because they use square root calculations. When possible, use Vector3.sqrMagnitude. 📌 Manually call System.GC.Collect() during loading screens or scene transitions. 📌 If you're getting large CPU spikes from garbage collection, then try incremental garbage collection. 📌 Disable/Enable MeshRenderer's using MeshRenderers.enabled. There is overhead activating and deactivating GameObject's with SetActive. 📌 Avoid calling DestroyImmediate. 📌 Store settings inside of ScriptableObjects instead of Prefabs. This avoids redundant variables allocated for prefabs using the same settings.
0 Comments
Leave a Reply. |
Me First Games is an independent game studio dedicated to creating unique and bizarre video games.
Red MatterStar Impact is an upcoming adventure platformer coming to PC, Mac, and Linux.
Archives
April 2021
Categories |
Copyright (c) 2020 Me First LLC
|