unity-mobile
Optimize Unity games for mobile platforms with IL2CPP, platform-specific code, and memory management. Masters iOS/Android deployment, app size reduction, and battery optimization. Use for mobile builds, platform issues, or device-specific optimization.
When & Why to Use This Skill
The Unity Mobile Optimization skill is a specialized assistant designed to help game developers maximize performance and efficiency on iOS and Android platforms. It provides expert guidance on IL2CPP compilation, memory management, and platform-specific C# implementation. By focusing on critical mobile constraints such as battery life, thermal throttling, and app size reduction, this skill ensures that Unity projects are architected for high-performance delivery on mobile hardware.
Use Cases
- Case 1: Optimizing game build size to meet the 150MB initial download limit for the App Store and Google Play Store.
- Case 2: Implementing platform-specific logic using C# preprocessor directives to handle different rendering APIs like Metal and Vulkan.
- Case 3: Reducing battery consumption and preventing device overheating by managing target frame rates and optimizing update loops.
- Case 4: Configuring mobile-specific texture compression (ASTC, ETC2) and audio settings to balance visual quality with memory constraints.
- Case 5: Profiling and minimizing Garbage Collection (GC) allocations to eliminate frame rate stutters on low-end mobile devices.
| name | unity-mobile |
|---|---|
| description | Optimize Unity games for mobile platforms with IL2CPP, platform-specific code, and memory management. Masters iOS/Android deployment, app size reduction, and battery optimization. Use for mobile builds, platform issues, or device-specific optimization. |
| - csharp-plugin | csharp-code-style |
Unity Mobile Optimization
Overview
Mobile platform optimization for Unity focusing on iOS and Android performance, battery life, and deployment.
Foundation Required: unity-csharp-fundamentals (TryGetComponent, FindAnyObjectByType, null-safe coding)
Core Topics:
- IL2CPP compilation and optimization
- Memory management and profiling
- Touch input and mobile UI
- Battery life optimization
- App size reduction
- Platform-specific code
Quick Start
// Platform-specific code
#if UNITY_IOS
// iOS-specific code
Application.targetFrameRate = 60;
#elif UNITY_ANDROID
// Android-specific code
Application.targetFrameRate = 30;
#endif
// Touch input
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Began)
{
HandleTouch(touch.position);
}
}
Platform Constraints
- iOS: Metal rendering, App Store guidelines, 150MB initial download
- Android: Vulkan/OpenGL ES, API level fragmentation, 150MB initial
- Memory: 1-2GB low-end, 4-6GB high-end
- Thermal: Throttling after 5-10 minutes
Optimization Checklist
- ✅ Texture compression: ASTC (mobile), ETC2 (Android), PVRTC (iOS)
- ✅ Audio compression: AAC (iOS), Vorbis (Android)
- ✅ Reduce draw calls: <100 mobile, batching
- ✅ IL2CPP optimization: Strip engine code, managed stripping
- ✅ Battery: Lower target framerate, reduce update frequency
Best Practices
- Profile on device: Not just Unity Editor
- Minimize allocations: Reduce GC pressure
- Touch-friendly UI: 44pt minimum touch target
- Handle pause: OnApplicationPause lifecycle
- Test on low-end: Target lowest common denominator