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
C# Journey into struct equality comparison, deep dive

A great post that dives into reasoning behind implementing IEquatable<>: where exactly allocations happen and that default ValueType Equals implementation uses structural comparison only for tightly packed structs, otherwise field-by-field comparison is used which utilizes reflection.
For us it means that we must implement IEquatable<> in our structs in case they are compared, which is common case when used in collections (dictionary, list, array, etc).

https://medium.com/@semuserable/c-journey-into-struct-equality-comparison-deep-dive-9693f74562f1

#performance #equals
👍6
Unity HDRP & ShaderGraph: Nodes that Bloat Shaders

It's nothing new that Shader Graph generates less-than-ideal code, but it's still interesting to examine in detail and see which more optimal solutions the author proposes.

https://justlukass.hashnode.dev/shadergraph-can-bloat-your-shaders-and-here-is-when

#performance #shader
👍3
Unity Assembly Definitions Explained: How to Organize and Control Your Code

This is definitely a good post that provides an overview of assembly definition settings and the benefits they bring. However, it's important to remember that any approach can backfire when taken to extremes. Having too many asm defs can significantly slow down your iterations. Even if compilation takes only seconds when your project is split into tiny assemblies, the domain reload would take much longer than compiling bigger assemblies, but in smaller quantities. Additionally, Rider needs to process all the assemblies, which also takes a lot of time, and this processing time seems to increase non-linearly as the number of assemblies grows.

Of course, the impact varies, and you should profile on your current hardware with your specific project. For me, 'too many assemblies' starts at around 500-600.

https://marcomignano.com/posts/unity-assembly-definitions-explained-how-to-organize-and-control-your-code

#asmdef
👍3
Estimating Early Access success

Analysis of steam reviews amount during early access.
Based on stats:
- if your game has less than 10 reviews in the first month of EA, then it's a miss.
- more than 200 it's a potential hit.

But in the end 200 is an arbitrary number the author has chosen, so don't make any targets or KPIs of reaching 200 reviews.

https://howtomarketagame.com/2023/08/21/estimating-early-access-success/

#marketing
👍3
The Weak Event pattern

Events in C# are a powerful mechanism for decoupling components and enabling a publisher/subscriber model. However, they have a significant drawback: the publisher holds a strong reference to the subscriber, and this can cause memory leaks. This article describes a pattern for implementing weak events in C#.

https://steven-giesel.com/blogPost/675b75fc-2c1b-43da-9ff8-42962ca8159b

#weakevent #observer
🔥3👍1
Godot is not the new Unity - The anatomy of a Godot API call

A very long, but very interesting read about calling unmanaged code in Unity and Godot.
Tbf Idk if the removal of Unity noscript language back in 2017 was a result of a similar issue Godot has now, but anyway Godot has a long road to achieve what the Unity team has done for noscripting performance and working with unmanaged code.

https://sampruden.github.io/posts/godot-is-not-the-new-unity/

#godot #performance
👍2
10 minutes to review the quality of any Unity project

A good read, and I've never seen a post regarding this topic before. It doesn't seem to come in handy for most developers in terms of real reviews of many projects, but it's definitely helpful to establish your own rules and guidelines for your projects.

https://medium.com/@wondrous_aqua_toad_341/10-minutes-to-review-the-quality-of-any-unity-project-6f7ce78f26fd

#review
👍6
Premature Optimization

The main point which I also always repeat in my own blog posts: profile first. Optimization might not even be needed in the first place. And without the baseline you can't even tell whether changes improved the performance or not.

https://youtu.be/tKbV6BpH-C8

#optimization
👍5
Everyday Unity
The Cost Of async/await On The Build Size Knowing how async/await works under the hood, I was interested in understanding the impact on the build size, as the compiler does its magic and for each async method generates the state machine consisting of hundreds…
In my blog post about the build size I used the build option Faster(smaller) builds to greatly reduce the size of code generation with IL2CPP.
In our company we had a chance to have a meeting with Unity engineers. At that time I asked what does this build option do under the hood and what drawbacks it has. But got no answer. Now the answer is in the docs:

When the “Faster (smaller) builds” setting is enabled only the single fully sharable version of generic code is compiled. This reduces the number of methods generated, reducing compile time and build size, but comes at the expense of runtime performance.

https://docs.unity3d.com/Manual/ScriptingRestrictions.html

#generic #genericsharing
👍8
Leveraging SerializeReference for Flexible Commands in Unity Game Development

There commands are bound via the inspector. In one of our previous projects, we employed a similar approach, but the commands were bound to events in the code within the composition root through a DI container.

https://medium.com/@gbrosgames/leveraging-serializereference-for-flexible-commands-in-unity-game-development-614e336b03b9

#command
👍2🔥2
Everyday Unity
Trying out new Unity API: BatchRendererGroup The goal of this post is to look at the new BatchRendererGroup API (BRG) and implement the minimal BRG example, so it is easier to understand how to work with it. Then gradually add more complex functionality.…
BatchRendererGroup sample: Achieve high frame rate even on budget devices

I wrote my own post about BRG and creating a sample year and a half ago when the documentation page was still empty. It took quite a while to figure out how to work with BRG by experimenting with code.
After some time, they filled up the documentation, but I still found it insufficient to get started with BRG without much effort. It's great to see a better sample and a very detailed blog post about it, even with such a significant delay after the initial announcement of BRG.

You can also check my blog post if you haven't yet, but the new one by Unity is more relevant now with more details and a bigger sample.

https://blog.unity.com/engine-platform/batchrenderergroup-sample-high-frame-rate-on-budget-devices

Repo: https://github.com/Unity-Technologies/brg-shooter

My sample: https://github.com/AlexMerzlikin/Unity-BatchRendererGroup-Boids/

My post: https://gamedev.center/trying-out-new-unity-api-batchrenderergroup/

#brg #instancing
👍4