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
Fake it ‘til You Make It: Faking Extended Draw Distance in Mobile Games

Developers of Block City Wars demonstrate a clever use of shaders and fog effects to fake distant objects, optimizing draw distance for better performance. In this game, players must be able to see the entire map from any position to avoid being at a disadvantage. Simply increasing the far clip plane isn’t feasible, as it raises the number of triangles passing through all culling stages. This means more objects undergo bounding box checks on the CPU and more fragments are processed on the GPU.

I encountered a similar issue while developing a car simulator set in an open city. We struggled because of the need to support multiple monitors, requiring separate cameras for forward, left, and right views, along with additional cameras for rearview mirrors.

Why not use a single camera with an ultra-wide FOV for forward, left, and right views? The answer is straightforward: to render 180 degrees, the FOV must be extremely high, resulting in unacceptable image quality due to severe distortions. This approach looked particularly bad on multiple monitors.

Instead, we opted for a combination of LODs, impostors, fog, and shorter draw distances for the left, right, and back cameras. Since players primarily focus on the forward view, this compromise worked well. And what was easier was that we didn’t need to render important objects all the time, as it was not needed for players to orient themselves using them.

https://www.gamedeveloper.com/production/fake-it-til-you-make-it-faking-extended-draw-distance-in-mobile-games

However, it’s unclear whether the solution includes LOD support for scaled-down meshes. If the distance is faked by scaling objects, then the high-poly version should be rendered, leading to high vertex density. This introduces performance challenges, as detailed in previous posts:
Vertex density
https://news.1rj.ru/str/everydayUnity/1634

Tips from the latest Unite https://news.1rj.ru/str/everydayUnity/2441

#rendering #culling
👍7🔥4
Unity’s TransformAccessArray — Internals and Best Practices

The TransformAccessArray in Unity is a specialized structure used for efficiently managing and accessing multiple Transform components, particularly in the context of jobs. It is designed to work with the Job System to allow parallel processing of Transform operations while minimizing overhead.
I tested this in my pet project a long time ago, and the difference was very noticeable, almost eliminating the cost of moving a large number of transforms every frame. While the API is pretty clean, working with jobs still adds cognitive load, so my advice is to always profile your code. Only if you see that transforms are the bottleneck should you switch from simple transform manipulations to using TransformAccessArray.

Tips from the Article:
- Use Burst.
- When a job only needs to read transforms (i.e., not write), use IJobParallelForTransform.ScheduleReadOnly.
- Break deep transform hierarchies into multiple transform roots whenever possible. This tip was also mentioned at Unite 2018 and in my post summarizing all performance tips from Unite.
- Review the desiredJobCount and innerloopBatchCount parameters. Aim for small enough values to keep all workers busy, but large enough to minimize the overhead of workers grabbing or stealing tasks too frequently.
- Prefer local space transform data like localPosition and GetLocalPositionAndRotation over world space data like position and localToWorldMatrix when possible.
- Reuse TransformAccessArray instances between frames; avoid recreating them unnecessarily.
- To remove a transform from the array, use TransformAccessArray.RemoveAtSwapBack instead of recreating the array. This is a general best practice for removing elements in hot paths.
- Avoid using transforms in a TransformAccessArray to store intermediary data between jobs. Transform access in jobs is slower compared to other alternatives.

https://medium.com/toca-boca-tech-blog/unitys-transformaccessarray-internals-and-best-practices-2923546e0b41

#optimization #performance #transform
🔥10👍2
UI Toolkit with Unity ECS - The Hot Path Show Ep. 3

In a free time I develop a pet project using Entities and
I've already mentioned The Hot Path Show here a few times promising to share my notes with insights from it. Even thought the videos are pretty long I find them very valuable as it always features the developer of Entities or the developer of a game made with DOTS and they share a lot of tips that might not be so obvious from the docs.

Here are my notes from the episode 3:
- ECB is slow, replaying the commands has a performance hit
- Dont use ECB all the time, default to use the main thread.
- If you see that parallelization is needed, then try to use native collections to gather entities and then perform the modification after the job
- Only if all the above is not working then use ECB
- Enableable components do not cause a not structural change
- EntityManager + EntityQuery is fast
- This is an example of fast entities destroying, since all of them in a one chunk
state.EntityManager.DestroyEntity(SystemAPI.QueryBuilder().WithAll<T>().Build());


- Dont use EntityQueryBuilder as its not burstable

I'd recommend you to check the show yourself, Since I am somewhat familiar with DOTS and Entities already, I might have missed some more basic advice. Would be great if anyone watching that shares the missed tips in the comments.
Drop a 🔥if you want more of similar recaps of videos and conference talks.

https://www.youtube.com/watch?v=bXR7EYacusI

#ecs #dots
🔥7👍4
Twenty Five Slicer

A Unity package designed for more advanced sprite slicing, enabling a "25-slice" approach. It divides a sprite into a 5x5 grid, allowing precise scaling and manipulation of individual regions while preserving key areas.
9 slices: Non-stretchable areas.
6 slices: Stretch horizontally only.
6 slices: Stretch vertically only.
4 slices: Stretch in both directions.

This allows for far more detailed slicing. Where traditional 9-slice images often require stacking multiple image layers to achieve complex UI shapes (e.g., speech bubbles, boxes with icons or separators at the center), a 25-slice configuration can often handle these scenarios with just a single image.

https://github.com/kwan3854/TwentyFiveSlicer

#sprite #slicer
🔥13👍6
ArtificeToolkit: A Unity toolkit that allows easy editor customization with simple C# attributes.

A pretty new open-source package that can help replace Odin Inspector. Normally, extending Unity's editor requires specialized knowledge of IMGUI or UI Toolkit libraries and maintaining separate files for each extension. ArtificeToolkit simplifies this by letting you use custom attributes directly in the source code to alter property appearances in the editor.

It might not cover all of Odin's functionality, but based on the denoscription, it includes everything I used in my project, so it looks good to me. I haven't tested it personally, though.
It's implemented using Unity's new VisualElements framework.

Also not mentioned in the documentation, but you can create Editor Windows as if they were simple components by inheriting the ArtificeEditorWindow class and calling through a menu item the GetWindow

https://github.com/AbZorbaGames/artificetoolkit

#editor #inspector
👍13🔥6💩1
Draw fewer tiles by using a dual-grid system.

How to create more rounded corners in a tilemap while using only 16 tiles instead of 47 to save runtime memory and reduce the effort of creating numerous tiles. This approach becomes especially crucial when working with animated tiles, as the tile count scales with each animation frame.

https://youtu.be/jEWFSv3ivTg

Demo: https://github.com/jess-hammer/dual-grid-tilemap-system-unity

The author also suggests a helpful tool for converting 15-piece sets to 47-piece sets: https://wareya.github.io/webtyler/

#tilemap #dualgrid
🔥6👍2
The Intelligent Mesh Combiner is a powerful Unity Editor tool designed to optimize your scenes by intelligently grouping and combining meshes based on their proximity and materials.

While I haven’t used this exact package yet, the underlying technique is highly effective for optimizing heavy scenes with numerous materials. I’ve had various experiences with this approach:
- Manually optimizing and combining 3D models in Blender.
- Using Asset Store solutions to automatically bake meshes in the editor.
- Developing a custom lightweight solution tailored to specific use cases.

This open-source package appears to offer a reasonable range of configuration options, making it a solid starting point if you don’t already have a tool for this functionality or have any issues with existing tool.

https://github.com/roundyyy/intelligent_mesh_combiner

#optimization #mesh
🔥14
Everyday Unity
UI Toolkit with Unity ECS - The Hot Path Show Ep. 3 In a free time I develop a pet project using Entities and I've already mentioned The Hot Path Show here a few times promising to share my notes with insights from it. Even thought the videos are pretty long…
Data-Oriented Damage System - The Hot Path Show Ep. 4

Continuing the series of sharing my notes from The Hot Path Show for everyone who uses DOTS and/or wants to learn more about it. Here are the notes for the video on implementing the damage system in ECS. Of course, it is not the one and only way to design and implement such a system, but it is a good starting point to learn how experienced developers use ECS.

- How to use the dynamic buffer buffer with the example of DamageElementBuffer to store multiple damage sources in one frame.

- 01:00:00 - You should create the entity and pass needed components instead of adding them in a separate method, because it leads to the entity being placed in one archetype and immediately moved to another.

- 01:01:00 - Since v1.2 you can use:
state.EntityManager.CreateEntity(stackalloc ComponentType[] { ComponentType.ReadOnly<T>(), ... })
This code is burstable. The old approach with using typeof(T) in CreateEntity was not burstable.

- 01:16:00 - Use [WriteGroup] to override groups with other systems.

- 01:18:00 - If you create your own ECB, use state.WorldUpdateAllocator instead of Temp or any other because this one is rewindable—it’s preallocated and clears every two frames.

- 01:38:00 - Example of ECB usage when you need to add a component not every frame and only in small quantities. ECB has a cost when doing a lot of operations.

Watch the episode: https://www.youtube.com/watch?v=SWXYpWtJZ5k

The sample project: https://github.com/TheHotPathShow/Episode-4

#ecs #dots
🔥7
This media is not supported in your browser
VIEW IN TELEGRAM
🌊 Uber Stylized Water

A highly customizable open-source stylized water shader for Unity 6.
URP
Rendering Path: Forward, Forward+, Deferred

I love that the author even provided documentation on how to use it, as well as multiple templates with various water styles.
I checked it myself, and it has tons of options to tune and adjust for your visual style. Definitely recommend checking it out.

https://github.com/MatrixRex/Uber-Stylized-Water

#water #shader #urp
🔥9👍1
imkoi/sparse-inject: DI Container forged for game development 

The fastest DI container developed by a friend of mine. I like his engineering approach and the overall high quality of the solution, which you can verify even by checking the benchmarks in the repo, as these are one of the most thorough benches for unity DI containers available online. They are conducted with a deep understanding of how a DI container is used in real games and how to measure performance correctly.

For example, benchmarks that prewarm the code in JIT-compiled environments don’t reflect real use cases, as in your game the registering stage is executed only once—unlike benchmarks where the building stage is run multiple times before measurements are taken. 

Moreover, the results vary significantly between Mono and IL2CPP. I recommend checking the benchmarks and results to remind yourself how crucial it is to profile your code and not blindly trust every claim made online (yes, I’m looking at you, benchmarks in Reflex and VContainer repos). 

Of course, the same applies to the benchmarks by the Sparse Inject author—if you're considering replacing your current DI container with this one, profile your code on the target platform with your existing DI container first. Then, after converting to Sparse Inject, compare the results. Ideally, test on multiple devices—the minimum supported, an average one, and a top-tier one—as performance gains may vary. 

I’ve started porting my pet project from VContainer to Sparse Inject. While I love the minimal API of Sparse Inject, it also means that everything VContainer provided for Unity integration needs to be redone manually. On one hand, VContainer’s Unity integration allows you to kick-start a project quickly, but on the other, it makes switching to another DI container more difficult later as you must redo all of that.
A minimal API of sparse inject requires additional steps now to implement integration features of VContainer I used, but in the future it also makes porting to another DI much easier since you gain complete control and understanding.

Nevertheless, I’ve shared my notes with the author so he can create a migration and quick-start guides. I believe that, sooner or later, a repository with add-ons for quicker Unity integration will be created — avoiding repetitive tasks while maintaining a clean API by keeping these additions separate from the main repo. 

https://github.com/imkoi/sparse-inject 

#di #container #dod
🔥24
With Android 15, Google introduced support for 16 KB memory page sizes in the OS. It is expected that device manufacturers will start bringing out devices with these capabilities to the market. Google’s testing suggests that there are noticeable performance gains in apps and games launching on 16 KB-capable devices, with up to a 10% improvement.

Support for 16 KB sizes is now available in the following Unity versions:

- Unity 6000.1.0b5 (expected release: February 9, 2025)
- Unity 6000.0.38f1 (expected release: February 14, 2025)
- Unity 2022.3.56f1 (released: January 15, 2025)
- Unity 2021.3.48f1 (released: January 22, 2025)

All native libraries in your project must be 16 KB compatible. Currently, the page size is 4 KB, and larger pages bring the following benefits:

- Lower app launch times under memory pressure: 3.16% lower on average, with more significant improvements (up to 30%) for some apps tested by Google.
- Theoretically reduced page table overhead: Since there are fewer pages to manage.
- Improved I/O performance: Larger pages require fewer read and write operations for data spanning multiple pages.
- Cache efficiency: Larger pages can lead to better cache usage, reducing the number of cache misses if your app has good data locality.

https://discussions.unity.com/t/info-unity-engine-support-for-16-kb-memory-page-sizes-android-15/1589588

#native #pagesize
🔥13👍2
Misconceptions about DOTS and Entities

Not every Unity developer has had a chance to work with the Entities package. So this is a good read to clear misconceptions surrounding DOTS. You should not be surprisied that you can use DOTS even without the Entities package in your project.

https://docs.google.com/document/d/18hFIQipNxTsKsWk9eRroRwkGgswWs6m40X8N4Kkjhy4/edit

#dots #ecs
👍7🔥2
Use Multiplayer Play Mode to test multiplayer functionality within the Unity Editor.

It was released almost a year ago, but I missed the announcement back then. Now that I've decided to work on a small co-op prototype, I find this tool amazing—it saves a lot of time. I remember how inconvenient it was to test a multiplayer game when I was working on my first multiplayer project around the time UNet was still relevant (8–9 years ago, if I'm not mistaken). To test it, I had to build a standalone version first, which took some time. Now, running multiple windows in Play Mode makes the process much faster.

Unreal Engine has had this functionality out of the box for a while, and I really liked it when I was creating another prototype to get acquainted with Unreal some time ago. So I'm very happy that Unity now offers the same functionality. Definitely recommend it if you're working on a multiplayer game.

https://docs-multiplayer.unity3d.com/mppm/current/about/

#netcode #multiplayer
👍10🔥7
And by the way, you can also set up the layout in the virtual player window, which allows you to debug more easily by having access to the console, scene view, and hierarchy.
🔥7👍5
Sampling vs. Instrumentation Profilers in Unity: When to Use Each for Better Performance

New Blog Post Alert!
It’s been a while since the last post on my website gamedev.center — lately, I’ve been deep into working on my pet project instead of writing. But finally, a new post is up!

I keep seeing Superluminal mentioned more and more—so is it time to take another look? 🤔

In this post, I break down sampling vs. instrumentation profilers, when to use each, and why a hybrid approach gives the best results. Plus, I share real-world profiling strategies that helped optimize Unity projects.

https://gamedev.center/sampling-vs-instrumentation-profilers-in-unity-when-to-use-each-for-better-performance/

#profiling #sampling
🔥7👍5
Easy Text Effects for Unity

An open-source Unity package for animating TextMeshPro text with customizable effects. Includes ready-to-use samples, real-time previews, and per-vertex animation capabilities.

https://github.com/LeiQiaoZhi/Easy-Text-Effects-for-Unity

#text #vfx
👍13🔥5
Everyday Unity
Easy Text Effects for Unity An open-source Unity package for animating TextMeshPro text with customizable effects. Includes ready-to-use samples, real-time previews, and per-vertex animation capabilities. https://github.com/LeiQiaoZhi/Easy-Text-Effects…
TMPEffects
Easily animate Unity text and apply other effects with custom tags

One more asset to animate TMP text. I briefly tried both and noticed they have different approaches to setup.
TMPEffects uses the tag system. While the previous one "Easy Text Effects" allows to combine effects by using presets and referencing them via the inspector.
I found this one more convenient for prototypes with the handy <tag> system (check the 2nd attached video). It looks ideal for quick prototyping.
The previous asset, EasyTextEffects, seems easier to customize, allowing you to tweak effects however you like. Both assets are solid and open source, so I am grateful the authors shared them with the community. I'd recommend checking out both, as some may find one setup more convenient than the other.

https://github.com/Luca3317/TMPEffects

#text #vfx
👍11🔥3