Unity Mobile Game Optimization Checklist
Is your mobile game plagued by lag, earning you terrible reviews? Poor performance crushes mobile games. This checklist gives you the essentials for optimizing your Unity game, turning sluggish gameplay into smooth, addictive fun.
Project Setup: The Foundation for Speed
A poorly configured project is a performance disaster waiting to happen. Nail these settings before you write a single line of code.
Optimize Target Platform Settings
Nail your API level (the Android version your game targets), architecture (ARMv7, ARM64), and graphics API (OpenGL ES vs Vulkan). Vulkan can boost performance but requires more setup. Split complex scenes to keep things manageable.
Choose the Right Scripting Backend: IL2CPP or Mono
IL2CPP often outperforms Mono, especially for CPU-intensive games. Benefit? Faster gameplay. Drawback? Longer build times.
Optimize Graphics Settings
Optimize textures, mipmaps, and overall quality. Lower resolutions and aggressive compression are key. Tailor settings to your target devices.
Configure Build Settings for Performance
Strip unused code that bloats your game. Enable code optimization for a speed boost. Create asset bundles to group related textures and models. This reduces load times and memory overhead.
If you are looking to populate your scenes with interesting structures consider using a Low Poly Fantasy Village to keep the poly count low and maintain smooth performance.
Asset Optimization: Every Byte Counts
Every byte counts! Optimizing your assets is critical for mobile performance.
Optimize Textures
Size matters. Use power-of-two textures (512x512, 1024x1024) for optimal efficiency. ASTC compression offers good quality and compression. ETC and PVRTC are alternatives, depending on your target platform. Mipmaps smooth out rendering.
Optimize Models
Less is more. Slash polygon counts, especially on distant objects. Optimize UV layouts to reduce texture sampling. Use Level of Detail (LOD) groups to swap in simpler models as objects move away.
Optimize Audio
Compress audio files. Reduce sample rates for sounds that don’t need high fidelity. Use occlusion and reverb to simulate realistic soundscapes without draining resources. FMOD or Wwise can provide advanced audio optimization, including dynamic mixing and prioritization.
Optimize Animations
Bake animations to reduce runtime calculations. Use animation compression to shrink animation data. Minimize the number of animated objects, especially those with complex animations.
Code Optimization: Lean and Mean Code
Lean and mean code is essential for mobile games. Here’s how to whip your scripts into shape.
Use Efficient Data Structures and Algorithms
Stop unnecessary allocations that trigger garbage collection and kill performance. Use object pooling to recycle objects. Optimize loops for speed. For example, instead of recalculating expensiveFunction()
within a loop on every iteration, calculate it once before the loop and reuse the result.
Manage Garbage Collection Effectively
Garbage collection pauses can tank your frame rate. Reduce garbage generation by reusing objects (object pooling) and minimizing temporary variable creation, especially within frequently called functions. Be mindful of string operations, as they often create garbage.
Follow Scripting Best Practices
Avoid heavy operations in Update()
. Use coroutines for tasks that don’t need constant updates. Profile your code to find and eliminate bottlenecks.
Leverage Burst Compiler and Job System
For complex tasks like pathfinding and physics calculations, use multithreading and SIMD via the Burst Compiler and Job System. These technologies allow you to distribute computationally intensive tasks across multiple cores, significantly boosting performance, especially on devices with multi-core processors.
Rendering Optimization: Maximize GPU Performance
Reduce Draw Calls for Faster Rendering
Batch static and dynamic objects. Pack multiple textures into one using texture atlases. Fewer draw calls means faster rendering.
Optimize Shaders for Mobile
Use mobile-friendly shaders. Simplify them by cutting calculations and texture lookups. Ditch expensive effects like complex reflections. You might find our article on Unity Shader Graph: Creating Custom Shaders Without Code helpful in optimizing your shaders.
Minimize Overdraw
Reduce overlapping transparent objects. Use occlusion culling to prevent rendering hidden objects. Optimize particle systems by reducing particle count and complexity.
Optimize Lighting for Performance
Bake lighting whenever possible to skip real-time calculations. Optimize real-time lighting by reducing shadow resolution and distance. Reduce the number of light sources, especially those casting shadows.
UI Optimization: Streamline Your Interface
Don’t let your UI drag down your frame rate! Smart UI design is key to mobile performance.
Minimize Canvas Count
Group UI elements with the same material into single Canvas Renderers. This reduces draw calls and improves performance. Mark static UI elements as non-dirty to prevent unnecessary redraws.
Optimize Text for Performance
Use TextMeshPro. It’s faster and more flexible than the built-in Text component. Optimize font sizes to save texture memory. Reduce text complexity by avoiding unnecessary formatting.
Use Sprite Atlases for Efficient Images
Use sprite atlases to combine images. Optimize image sizes to reduce memory. Only add UI elements that are essential.
Use Efficient Auto Layouts
Use auto layout to adapt your UI to different screens. Avoid complex nested layouts – they eat up performance.
Master Memory Management: Stop Leaks, Boost Performance
Unload Unused Assets
Unload unused assets to free up memory using Resources.UnloadUnusedAssets()
or Addressables.
Profile Memory Usage
Hunt down memory leaks and excessive usage with Unity’s Memory Profiler.
Use Addressables for Granular Asset Control
Use Unity Addressables System: A Complete Guide for asset management to control loading and unloading.
Control Texture Memory
Stream mipmaps to load only what’s needed. Reduce max texture size in quality settings based on the target device’s memory.
Profiling and Debugging: Find and Fix Problems
If you are looking for assets, Strafekit provides developers with unlimited game assets to use in their projects.
Use Unity Profiler to Find Performance Bottlenecks
Analyze CPU usage, rendering, and memory allocation to pinpoint bottlenecks.
Use Platform-Specific Profilers
Use Xcode Instruments (iOS) and Android Studio Profiler to find platform-specific issues, such as GPU bottlenecks or memory leaks.
Use Debugging Tools to Catch Errors Early
Fix errors that hurt performance, such as null reference exceptions or infinite loops, using Unity’s debugging tools.
Monitor Runtime Performance
Implement runtime performance monitoring and display to provide feedback and identify potential issues. Use the UnityStats
class or third-party plugins to track metrics like frame rate, CPU usage, and memory usage. Display this information in-game to quickly spot performance drops during gameplay.
Testing and Iteration: Rinse and Repeat
Test on Target Devices
Test on a variety of mobile devices to ensure consistent performance across different hardware.
Gather User Feedback
Actively solicit user feedback on specific performance issues. Pay close attention to reports of frame rate drops and long loading times on various devices.
Perform Iterative Optimization
Continuously optimize based on profiling data and user feedback.
Perform Regression Testing
Use the Unity Test Runner or automated performance tests to ensure optimization changes don’t introduce new issues.