Everyday Unity – Telegram
Everyday Unity
1.11K subscribers
157 photos
59 videos
42 files
2.36K links
A game developer and tech lead in a top grossing company posting Unity, programming, and gamedev related stuff that I find interesting
Website: https://gamedev.center

Most used tags are:
#performance
#shader
#interview

Author: @alexmtr
Download Telegram
Unity Asset Bundles tips and pitfalls

A helpful list of tips for working with asset bundles. It provides just enough detail to explain why each tip is useful, while keeping the post concise.

https://unity.com/blog/engine-platform/unity-asset-bundles-tips-pitfalls

#assetbundle #tips
🔥5
I'm visiting Unite 2024 and wanted to share a high-level overview of the talks I attended and found interesting.

The first one was Making Prince of Persia: The Lost Crown.

The speakers presented several key ideas, including the importance of automated testing. They specifically mentioned automated performance testing using custom tools built on top of Unity’s provided systems. My favorite was a custom tool called the "performance map reporter," which shows frame times for each location. This tool helps quickly analyze how new content and code changes impact different areas of the game.

Here’s an overview of the key technologies and tools they use:

Unity 2021
A forked URP (Universal Render Pipeline)
Houdini for content design
Extensive use of addressables for streaming
Scriptable Build Pipeline
Bake visible vertices and cull invisible ones to save 40-60% in build size
Custom post-processing stack
Combine procedural geometry into 64k vertices chunks for optimized static batching, reducing draw calls from 2k to 500
For animations, they use Jobs Skinning on the CPU, which provides better performance for them compared to GPU compute skinning
Background animation is baked into textures and animated in the shader
Use of constant buffers instead of uniform constants
Ubershader instead of Shader Graph
Object pooling, avoiding the use of strings

If you're here at Unite too, I'd be happy to meet up. Hit me up in direct messages; my contact is in the channel denoscription.
🔥12👍1
🔥13
Another talk I attended yesterday was Accelerating the Creation of Your Competitive Multiplayer Game. It was a brief demonstration on how to set up rotating cubes in multiplayer using Unity services, so nothing particularly special.

The second part of the day consisted of private meetings with Unity about Vivox, Muse, and Asset Manager, discussing how these tools could solve our challenges.

Vivox has been around for many years, so nothing new there.

Muse: There are plans for integrating an AI agent into the editor, which could help with simple, repetitive, and tedious tasks.

Asset Manager: This tool bridges the gap in the production pipeline between artists and developers, providing a way to review and deliver new assets into Unity projects.

What is more there is already a video available about upcoming changes: https://www.youtube.com/watch?v=80Jw4orjvuk.

There are a lot of interesting changes ahead and some insights: DOTS is alive, rendering pipelines are being unified, UI Toolkit is expected to be greatly improved to be on par with uGUI in Unity 7, and if it goes well, then the old gui will be deprecated in 8. Overall, with the new CEO, I like the direction the company is taking and its interest in addressing the pain points of studios that use Unity. Of course, they do this as part of the services they're heavily promoting, but I still noticed a strong interest in our feedback.
🔥3👍1
The next talk was Boosting Your Game Performance with Profilers in Unity 6

This is a basic overview of how to use a profiler in Unity 6. There are some quality-of-life improvements, such as target frame rate settings and a simplified view to easily identify if the bottleneck is in CPU or GPU. However, if you're already familiar with the profiler, this talk can be skipped.

Takeaways:
It's important to know your performance budget before starting the game so you can identify when optimization is needed.
Additionally, manual profiling can be time-consuming, so automated profiling and data analysis can yield great results, especially if your game has strict performance limitations.

In the project I'm working on, we’ve already implemented automation for performance metrics. The next step is to extend the system to gather and analyze more detailed data, allowing us to more quickly identify where performance degradation happened
👍7🔥1
The second day started with Deep Impact: Optimizing Outer Wilds for a New Platform

The Unity team talked about how they helped port the game to Switch. The structure of the talk was less than ideal as they hardly shared any before-and-after comparisons using profilers, but it still contained a lot of useful tips. Since the game is now released on Switch, let’s assume everything worked well.

Main takeaways:
- Updated Unity to a newer version (questionable, but it helped them)
- Implemented a custom occlusion culling system tailored to their specific use case (this is a big takeaway, as Unity’s default systems are usually made to fit general needs, while a custom system can be designed to do exactly what's required, saving resources; of course, you have to profile and weigh the development and support costs against the potential benefits—no need to do it for things that aren't causing issues)
- Collider optimization: simpler mesh colliders and primitive colliders
- Combined small geometry in chunks of 64k vertices using jobs, and split large ones
- Swapped meshes for simpler ones when it wasn’t noticeable to the player
- Used LOD + HLOD
- Reduced vertex count without compromising quality
- Used fewer unique materials
- Enabled dynamic resolution
- Switched to Addressables instead of Resources
- Set asset loading priorities to load the most important assets first
- Replaced the standard shader
- Streamed textures and mipmaps
- Used burstable code

I’m also adding a picture with their takeaways. However, I slightly disagree: you should never optimize just because "it's almost always a good idea." Always profile first to ensure optimization is necessary, and then verify with the profiler after that the optimization was successful. Also, parallelization can bring great benefits, but not in all cases—synchronization can sometimes be even slower than the initial computation. That's why I love so much talks by Ian Dundore at Unite, because he also pushed that great idea.

So my conclusion would be:
Always profile, only you know your game and your particular case. Do optimizations according to that and verify every change.
👍9🔥2
🔥4
The next talk at Unite 2024 worth mentioning was "Best Practices for Reducing ANRs on Android"

Highlights:
- The ANR timer may vary from vendor to vendor. The default is 5 seconds, while some Samsung devices have 10 seconds.
- ANR rate affects app discoverability.
- The main thread and Unity thread are two separate threads. Thread.Sleep() blocks the main thread, but not the Unity one, so animations can still run in the background.
- Unity published a test game to the store to track ANRs. An update to the 2021 version had the biggest impact, reducing the ANR rate from 3.5% to 0.4%. If you're still experiencing issues on older versions, consider updating. We saw a similar effect with a significant reduction after updating for our game, though our old rate wasn't that bad.
- They also broke down top ANRs. TL;DR:
- NativePollOnce: Can be ignored.
- PerformPause: Unity Android player syncs with the engine for more than 4 seconds.
- NativeUnitySendMessage: Too much workload on resume triggered from native callbacks.
- For debugging, use Android Strict Mode to identify performance issues and long I/O on the main thread.
- Check the ANR playbook on the Android Developers Portal.
- Update to Unity 6 or 2022.3.10 to reduce the ANR rate even further by 20-40%.
- Unity 6 can embed debug symbols into the app bundle to simplify the uploading process.
- Unity 6 has GameActivity, which supports better threading.

I am also adding a few slides from that talk that I find interesting and that speak for themselves
🔥10👍3
🔥14👍1
The final talk of the conference, and the one I was most excited about: "Performance Tips & Tricks from a Unity Consultant."

I wanted to attend this session because one of my favorite talks ever at Unite was on the same topic by Ian Dundore. I learned a lot from it. I even wrote a post about all the tips from that session, which has helped me many times: https://news.1rj.ru/str/everydayUnity/1623

While I didn't learn a lot of new things this time, the talk was still very good overall.

Highlights:
- Use native profilers such as SuperLuminal. The Unity profiler shows a very limited call stack, and in deep profile mode, too much performance is consumed by capturing the call stack. Results become increasingly skewed the deeper the stack is.
- Prewarm your shaders and use shader variant collections (SVC). However, SVC is not supported by all graphics APIs.
- More improvements for graphics and shaders are coming in Unity 6, so they encourage updating.
- Use the SRP batcher and ensure your shaders are SRP batcher-compatible.
- Use instancing for more than 100 identical meshes. This is interesting because a few years ago it was suggested that instancing should be used from 1024 meshes. I suppose this should be tested in Unity 6 with specific use cases to confirm.
- I also asked during the Q&A which low-level API he recommends, and he suggested using BRG (I have written a blog post about this as well a long time ago when BRG was just released https://news.1rj.ru/str/everydayUnity/1716).
- Avoid quad overdraw. I shared a great post about this some time ago: https://news.1rj.ru/str/everydayUnity/1634.
- Basic shader advice: use half/int16 where possible, reduce the number of variables, and minimize texture samples.
- One particularly interesting point was about memory allocations: Boehm allocates memory in 4KB blocks, and a block isn't freed until all buckets within it are free. Because of this, you should allocate long-term memory together so it’s placed in the same block.
- Avoid multiple cameras, as each adds significant overhead. Use render features instead when possible.
- Mix UI and 3D with camera space UI.
- Use the resident drawer in Unity 6 for repeating meshes where draw calls are a bottleneck.
- Avoid duplicates in Addressables. Use the Addressables Analyzer, Build Reporter, and Memory Profiler's potential duplicates tool to find duplicated assets.
- Untracked memory in the Memory Profiler might not be an issue; native profilers can help determine that.
👍5🔥3