Yeah it's also something I realized _after_ the video was completed, it might just be because the original one used URP, and Built-in is faster. But apparently it's not, it's due to other project settings. Which leads to the same conclusion of: take the time to tweak your project settings if you want extra performance.
@@uselessgamedev URP absolutely slows down the editor (not sure about runtime) to an absurd degree. More annoying, it seems related to the inspector so it slows down and speeds up depending on how much you're moving the mouse and what you have selected
5:35 Don't use the FPS as a measurement, use milliseconds per frame. That way, you will see each project got a (very small) boost, like 0.05 ms less per frame.
Here's one that, in my tests, gave an 8x improvement in frame-time: avoid using unity's reflection-based "event" functions (eg. Start, Awake, Update, FixedUpdate). If you create a singleton that receives the unity "events", you can architect your MonoBehaviours (via base class) to register and deregister themselves to the singleton, which will then directly call the relevant methods through either C# events, or lists of interfaces (eg. IFixedUpdateable, IAwakeable). I don't use Unity nowadays, so unfortunately I didn't get much use out of this after I figured it out, but hopefully it helps others. Unity's 'events'/'messages' are based on runtime reflection, which comes with an absolutely insane amount of overhead. I've never understood why they thought building the application code on the top of reflection was a good idea, especially since when they first architected it, reflection was even slower than it is now.
Oh 100%. You could even put your singleton in the playerloop. But it's certain the SendMessage/Broadcast message system is a performance sinkhole, and the events (Update etc) cannot be much better
from what I know, Unity messages do not use reflection (SendMessage might be, but not Start, Update, etc.). A quick search on google will have you this: "The first time a MonoBehaviour of a given type is accessed the underlying script is inspected through scripting runtime (either Mono or IL2CPP) whether it has any magic methods defined and this information is cached. If a MonoBehaviour has a specific method it is added to a proper list, for example if a script has Update method defined it is added to a list of scripts which need to be updated every frame. During the game Unity just iterates through these lists and executes methods from it." So what you're doing is essentially reinventing the wheel, minus the checks so you have more performance. Checks here include the auto-removal of null/invalid "IUpdateable"s from a list while iterating, handling exceptions and so on.
IIRC this is not entirely true. There's a blog post from Unity saying they don't actually call methods through reflection. They register the methods through reflection at compile time/some other pre-processing step and there is no runtime reflection.
loving this video but a minor gripe: measure performance in ms, not fps, fps is hard to compare due to being inverse. if you cut frame time by 16ms you go from 30fps to 60, or from 10 fps to 13fps, same improvement but one seems way more impressive!! gamers might not understand ms vs fps but we're smart game devs so we don't need to worry about that for performance discussion
Honestly? Unity's issue is not really that it's builded games are bloated, rather the editor itself is. God unity 2022 LTS was an absolute PAIN to use, Unity 6 is miles faster in that regard but still slower than the old days of unity 2018 & 2019
Unfortunate how all game engines just seem to get bigger over time. I just checked the size of a game jam game I made in 2017 with Unity, and that was 39MB without paying any attention to the size of the project. And it had 3D graphics, unlike the project in this video.
A blank project should be about 30mb. Surely your couple of images can't bump it to 80mb! This is why I have settled on older versions of Unity. They provide negative value with each update. I clearly remember going from Unity2019 to Unity2021 in-editor compile times went from ~1 second to 3-5 seconds.
I'd love to see a whole series on this with at least one video for every engine. Might be really cool to write an engine from scratch and talk about the best ways to optimize it.
@@sechmascm Do you enjoy writing boilerplate code that you have already written over and over again? Even if you write an engine generically, you'll just be duplicating the preexisting engines. Better to just start writing your game, unless you're only doing it for a learning experience.
@@anon_y_mousse Well, you can start from the step just below the comercial engines. No need to write a compiler from scratch, but there are existing libraries that give you control over what you want to add. I'm not even an engine purist, but if you want a comercial engine to be perfectly optimized for your project it'll be hard to find one. I know you can modify and recompile Godot (if you know C++), but Unity and Unreal Engine could be lost cases in that regard. The tech debt will carry over no matter what
there is (or was?) a light version. i dunno how to find it, but it was presented some time ago. they marketed it for mobile games, that want to be as small as possible, only using the bare minimum
The only thing I can find is an APT attacking some CI/CD servers running JetBrains' TeamCity, and a Trojan allegedly being distributed disguised as a crack for JetBrains IDEs. I don't think either is really of great concern for the everyday developer?
Agree! But for build sizes. Defold and GameMaker Studio 2 are even better ;-) Godot export templates could be rebuilded with less modules tho - still not as small as Defold and GMS2 xD
man unity is so cooked, I remember back in the day before all this modular subsystem bs there was just a single unity runtime dll and a build would be like 15mb total
@CadaverKuma The entire point of a package system is that you can have a lean core and only include modules you need. But instead of getting leaner Unity just got slower and more bloated, that's just objectively a failure. Doesn't mean it can't still be the best engine for your usecase of course, but I think the drastic decline in popularity and share price proves I'm not alone in thinking Unity messed up.
@CadaverKuma Also apparently project tiny is _still_ in preview lmao, so that isn't even an option. I used Unity for 8-ish years and in that time they've *always* over promised and under delivered.
@@pokefreak2112 The planned switch to CoreCLR is hopefully gonna speed it back up to the levels of Unity 5. Probably gonna be in a beta next year or something
You can edit the manifest file to include only the packages you want. Its just a json file so you can save it and every new project you just replace it with your edited one and unity will automatically add and remove packages.
The reason the empty project is faster is because it’s using different default project settings, not bloat.
Yeah it's also something I realized _after_ the video was completed, it might just be because the original one used URP, and Built-in is faster. But apparently it's not, it's due to other project settings. Which leads to the same conclusion of: take the time to tweak your project settings if you want extra performance.
@@uselessgamedev URP absolutely slows down the editor (not sure about runtime) to an absurd degree. More annoying, it seems related to the inspector so it slows down and speeds up depending on how much you're moving the mouse and what you have selected
@@uselessgamedev you should probably delete the video
5:35 Don't use the FPS as a measurement, use milliseconds per frame. That way, you will see each project got a (very small) boost, like 0.05 ms less per frame.
Did you know that you can disable many of the default things by going to Package Manager->Built-in?
This
Came here to say the same after watching 2 minutes - that's...a bit embarrassing ^^"
Here's one that, in my tests, gave an 8x improvement in frame-time: avoid using unity's reflection-based "event" functions (eg. Start, Awake, Update, FixedUpdate). If you create a singleton that receives the unity "events", you can architect your MonoBehaviours (via base class) to register and deregister themselves to the singleton, which will then directly call the relevant methods through either C# events, or lists of interfaces (eg. IFixedUpdateable, IAwakeable).
I don't use Unity nowadays, so unfortunately I didn't get much use out of this after I figured it out, but hopefully it helps others. Unity's 'events'/'messages' are based on runtime reflection, which comes with an absolutely insane amount of overhead. I've never understood why they thought building the application code on the top of reflection was a good idea, especially since when they first architected it, reflection was even slower than it is now.
Oh 100%. You could even put your singleton in the playerloop. But it's certain the SendMessage/Broadcast message system is a performance sinkhole, and the events (Update etc) cannot be much better
Hi, could you try explaining that in a beginner friendly way because i am interested
from what I know, Unity messages do not use reflection (SendMessage might be, but not Start, Update, etc.). A quick search on google will have you this:
"The first time a MonoBehaviour of a given type is accessed the underlying script is inspected through scripting runtime (either Mono or IL2CPP) whether it has any magic methods defined and this information is cached. If a MonoBehaviour has a specific method it is added to a proper list, for example if a script has Update method defined it is added to a list of scripts which need to be updated every frame. During the game Unity just iterates through these lists and executes methods from it."
So what you're doing is essentially reinventing the wheel, minus the checks so you have more performance. Checks here include the auto-removal of null/invalid "IUpdateable"s from a list while iterating, handling exceptions and so on.
IIRC this is not entirely true. There's a blog post from Unity saying they don't actually call methods through reflection. They register the methods through reflection at compile time/some other pre-processing step and there is no runtime reflection.
I turned on Managed Code Stripping and cut my build size by 2mb 😎
🤘
bro breaking the unity of unity
You can also change compression settings for smaller build size.
Why is your project still so large? I got a 3D, first person horror game with sound and music down to 38Mb!
HOW
@@successor0 Leaning on a style using low poly and a few basic textures run through a shader.
He probably didnt compress the textures
@@successor0also check build logs it shows which assets have which size consumption
Unity Player alone is >30mb. All your assets, scenes, resources and managed libraries fit into 8MB? Bullshit.
I like the *foreshadowing*
loving this video but a minor gripe: measure performance in ms, not fps, fps is hard to compare due to being inverse. if you cut frame time by 16ms you go from 30fps to 60, or from 10 fps to 13fps, same improvement but one seems way more impressive!!
gamers might not understand ms vs fps but we're smart game devs so we don't need to worry about that for performance discussion
False advertising. this is Useful game dev.
Honestly? Unity's issue is not really that it's builded games are bloated, rather the editor itself is.
God unity 2022 LTS was an absolute PAIN to use, Unity 6 is miles faster in that regard but still slower than the old days of unity 2018 & 2019
Yeah I look forward to the switch to coreCLR I think it will vastly improve performance
Unity 2020-21 is the fastest
Unfortunate how all game engines just seem to get bigger over time. I just checked the size of a game jam game I made in 2017 with Unity, and that was 39MB without paying any attention to the size of the project. And it had 3D graphics, unlike the project in this video.
Could you use Project Tiny / DOTS runtime? I’ve never used it, but it might be an improvement.
Isn't project Tiny discontinued? If not, that would be a great lead for a new default template
@@uselessgamedevTiny turned into DOTS, but it's not tinying the same way
As a gamedev myself, I love your channel!
As a full time C# web dev. JetBrains Rider is AWESOME! it's great seeing them sponsor youtubers
A blank project should be about 30mb. Surely your couple of images can't bump it to 80mb!
This is why I have settled on older versions of Unity. They provide negative value with each update. I clearly remember going from Unity2019 to Unity2021 in-editor compile times went from ~1 second to 3-5 seconds.
I wonder if we can dnSpy-hack the game to exclude the unnecessary code in build.
I'd love to see a whole series on this with at least one video for every engine. Might be really cool to write an engine from scratch and talk about the best ways to optimize it.
The most optimized game engine is the one made for that one specific game. You only add what you want/need
@@sechmascm If you don't enjoy programming then fine, but some people do.
@@anon_y_mousse What are you on about? lol I was saying that you have to make your own engine... I don't follow your logic
@@sechmascm Do you enjoy writing boilerplate code that you have already written over and over again? Even if you write an engine generically, you'll just be duplicating the preexisting engines. Better to just start writing your game, unless you're only doing it for a learning experience.
@@anon_y_mousse Well, you can start from the step just below the comercial engines. No need to write a compiler from scratch, but there are existing libraries that give you control over what you want to add. I'm not even an engine purist, but if you want a comercial engine to be perfectly optimized for your project it'll be hard to find one. I know you can modify and recompile Godot (if you know C++), but Unity and Unreal Engine could be lost cases in that regard. The tech debt will carry over no matter what
unsubscribed this is useful game dev
Source Code (this code only for free share can be possible) ??
there is (or was?) a light version. i dunno how to find it, but it was presented some time ago. they marketed it for mobile games, that want to be as small as possible, only using the bare minimum
Project Tiny it was called. I don't know if it's officially canceled but the package doesn't get a lot of activity these days
What is that background? It looks really cool!
It's three sobel filters applied to a two sliding gradient noises multiplied together
did you know running a baguette through a vampire's heart is a painstaking process?
Premature optimization moment
A lot of people are just considering ditching Unity entirely.
A gazillion quadrillion of a billion people are considering leaving unity 🤯 🤯
I m french and je valide la baguette
Great video! Didn't jetbrains have a malware or keylogger controversy a while back?
no
no they did not
From looking it up, it sounds like Russian hackers tried to exploit older versions of JetBrains, but I don't see much else.
The only thing I can find is an APT attacking some CI/CD servers running JetBrains' TeamCity, and a Trojan allegedly being distributed disguised as a crack for JetBrains IDEs. I don't think either is really of great concern for the everyday developer?
what????
You would love Godot!
Agree!
But for build sizes. Defold and GameMaker Studio 2 are even better ;-)
Godot export templates could be rebuilded with less modules tho - still not as small as Defold and GMS2 xD
@@igorthelightyou can strip editor features you don't need from the editor settings as well
man unity is so cooked, I remember back in the day before all this modular subsystem bs there was just a single unity runtime dll and a build would be like 15mb total
Its not BS my man, they don’t appeal to you, then aight, don’t use it…
@CadaverKuma The entire point of a package system is that you can have a lean core and only include modules you need. But instead of getting leaner Unity just got slower and more bloated, that's just objectively a failure. Doesn't mean it can't still be the best engine for your usecase of course, but I think the drastic decline in popularity and share price proves I'm not alone in thinking Unity messed up.
@CadaverKuma Also apparently project tiny is _still_ in preview lmao, so that isn't even an option. I used Unity for 8-ish years and in that time they've *always* over promised and under delivered.
@@pokefreak2112 always bringing up the price changes from over a year ago 😭.. brother, the whole team changed from the board to the ceo
@@pokefreak2112 The planned switch to CoreCLR is hopefully gonna speed it back up to the levels of Unity 5. Probably gonna be in a beta next year or something
Later, the govt made Baguette Clicker the French national video game. Congratulations! 🎉🇫🇷🥖
The original title I planned was _Paintastic_ but I couldn't be bothered to make a visual for it
Or, you know, just uninstall the built-in features you don't use from the package manager 😜
I appreciate the effort tho ^^
This is hopeless 😂
Just try defold if you want 5MB build size
boids!
all your videos are good
Hey, Nice!!!
useless game dev? all i see are gold
You can edit the manifest file to include only the packages you want. Its just a json file so you can save it and every new project you just replace it with your edited one and unity will automatically add and remove packages.