Do you have plans to optimize your game made with Unity and get the best performance? If you think you are in need of some expert advice or help, let us help you with it. Welcome to Supercode Games, where we release games, talk about games, gaming techniques, and keep you updated on the gaming world’s exciting insights.
Unity Optimization is a process that helps you make your game run better. Usually, optimization is required to make the gameplay smooth and fast available to a broader audience. This way, the game also runs better on lower-end devices.
The Unity Profiler is the primary tool to profile the Unity Projects and the beginning of every Unity optimization process. You can find specific bottlenecks from the information provided by it from where the first optimization tasks are created. Learning its use helps to understand the work of the Unity Engine and the Current Project. It provides adequate and reliable information on the different performance areas of a project that are listed below.
- CPU and GPU Usage
- Physics (2D & 3D)
- Rendering Information
- Memory usage
- Audio and Video systems
- Global Illumination
- Network Messages and Operations
Using the Profiler
Unity Profiler is to be connected to a running build for it to work. Profiling your game requires four essential steps.
- Unity Profiler
- Remote Profile
- Editor Log
- Test regularly on different devices
UI in Unity
Here are some of the most effective tips and tricks that can be useful for mobile optimization in Unity.
- Be sure that the sprites as less transparent in the best possible way.
- Add all your UI Sprites into an atlas reducing the maximum size to a minimum level.
- Generating the Mip Maps option in UI will offer effective rendering and provide a smooth screen display.
- Having a few canvases are important in optimization.
- Remove the ‘Graphic Raycaster’ component if canvases are only used for display without interaction.
- Uncheck the ‘Pixel Perfect’ option to see great results, especially with Scroll Rects.
Texts and Images
- Uncheck ‘Rich Text’ if your content is straightforward and doesn’t require any complicated alternate texts.
- Uncheck ‘Raycasts Target’ if image and text components don’t interact.
- Do not use the ‘Best Fit’’ option on too many Texts.
- Try to keep the count fonts small and a reliable count.
- Disable the ‘Best Fit’ option on all the text components.
- Create a new material and set its shader to ‘UI/Default’ before putting this material on every image and text.
Rect Mask 2D
- This one also has the advantage of disabling UI elements, like Mask Component, outside the mask area and not rendered.
- Try not to use too much of the Scroll Rects because they are not optimized for the mobile versions.
Canvas Group and Menu Animations
- Disabling and enabling can restart processes for certain GameObjects.
- Use Canvas Groups to group elements and control their behavior as a whole.
- You can play with the opacity, ‘Alpha’ of the group, and disable the interactivity with the ‘Intractable’ and ‘Block Raycasts’ options.
- Use mobile shaders only for a better impact.
Some quality settings like the rendering, shadow effects, and other interesting settings are maintained at a certain point for better optimization. Some of them are listed below.
- Lower the ‘Pixel Light Count’ to 1 or 0 if you don’t have any lights
- Disable the anti-aliasing
- Disable the soft particles
- Shadows to ‘Hard Shadows Only’
- Shadow Resolution to ‘Low/Medium Resolution’
- Shadow Projection from ‘Stable Fit’ to ‘Close Fit’
- Tweak the ‘Shadow Distance’ value – 60 or less
- Shadow Cascades to ‘No Cascades’
- Blend Wights to ‘2 Bones’
- LOD Bias to 1
- Particle Raycasts Budget to 256
- Set Levels for Standalone -> Fantastic, Android & iOS -> Simple
When it comes to textures, enabling ‘Generate Mip Maps’ helps faster texture loading time and lower rendering time. There are other points you need to remember.
- Take their purposes like Character Texture, UI Sprites, Environment Texture, etc., into account.
- Try to reduce the ‘Max Size’ as low as possible.
- Use Texture Atlas to reduce the draw calls.
While using the scripts feature, make fair use of qualities like coroutines, events, actions, reactive programming, and Raycasts to detect your touchable GameObjects. This is not the case in UI, though. We would also suggest that you don’t put everything in Update ().
We believe it is better to have the least dynamic Rigidbodies and use simple primitive colliders instead of mesh colliders. Keep the collision detection mode on a discrete version and tweak the fixed timestep value a little. This way, it can represent the duration between two calls of the FixedUpdate() method.
When it comes to lighting, we suggest you do not use the dynamic lighting and opt for the unlit textures. Using light probes can help you gain the advantages of dynamic lighting. Begin the process by setting the culling mask with only the layer of GameObjects you want to project light upon. Faking the dynamic shadows using Shadow Projector can be useful too.
Listed below are the top practices that we have for you that can be considered the best of the best.
- Hierarchy arrangements
- Compress 3D Models
- Produce the images as ‘Square’ to minimize the impact on processors
- Static batching
- LOD and HLOD Systems
- Universal render pipeline
- The terrain to mesh conversions or terrain optimizations
- Target 60 FPS
- Half resolution
- Remove unused assets using Asset Hunter PRO
- Occlusion culling
- Adjust near and far clipping planes on camera
- Clear all warnings or errors