Hi. This series is something much needed, thanks a lot. With respect to the recommendation about using preprocessing directives to eliminate properties: I had the notion that this kind of simple properties were inlined by the compiler in non-editor, or at least non-debug, builds. Why do why need to use this kind of tricks? Are this kind of properties not usually inlined? What about using AgressiveInlining with the MethodImpl attribute, would that make them be inlined?
In normal .NET they would be inlined by JIT usually by default. No idea if Unity3D does something terrible such as removing inlining from JIT or something from their customized runtime.
A note for myself: - Functions use the stack, fast, Class instances use the heap, be careful - If you have lots of objects, use a scriptable object to save shared properties - Choose the correct data structure - Use object pooling, decide how big the pool is - Properties (those with get and set) have an overhead, prefer just using fields aka variables, as shown here - Use the addressable asset system, since the resources folder slown down load time - Remove empty events when not using them - Activate or instantiate objects after the first frame, sine you might have too much things on start() and awake() - 22:33 When you change something using a string, compute the hash - Avoid complex hierarchies in your scene tree - Disable the accelerometer if not used - Move rigid bodies with their methods in fixedUpdate()! - Cache your references if you need to use thigns like Find()
A lot of these tips i knew were good practice but i didnt really understand *why* before watching this video. Thank you very much for the presentation 🙏
Awesome useful video. Have already watched tons of optimization videos before but some of tips were really new and useful. I need hundreds of such tips xD.
I would like an in depth/ practical example of getter/setter optimization. How much up a real performance boost are we talking? Are we talking better memory management or reduce load?
It really depends. In most cases the real benefit will be close to zero. But just to provide an answer, the benefit is because without getters/setters you basically avoid calling another function.
Super interesting video. Unfortunately, certain subtleties of the English language have left some areas of fog ... This is why I thank you warmly for using a presentation, which made viewing easier. I look forward to a sequel.
Hello Jean-Michel, yes. the subtitles are not the best (they are generated by UA-cam I think). Here's the presentation with the notes. Hope it helps docs.google.com/presentation/d/1A3MQJef-WzH1gE9pYOfQz8SeodBSE2sUJv8b1-PlXCA/edit?usp=sharing
@@ArturoNereu Thank you very much for the link, the presentation is more complete than the video. The graphics and audio tips are very interesting. I have questions about slide 46 (audio import settings): - on the slide, you mention Vorbis for Android: what is it about? To use in priority or not to use? - in the notes, a Quick Guide to configure the audio settings is indicated, but I did not find the link. Could you tell me where to find it?
Is there an overhead of a complex hierarchy even if we don't define a method OnTransformChanged in our components ? Isn't the matrix of a Transform flagged for recompute and only recomputed if we access it ?
While these are very basic tips, I don't quite understand the need for ScriptableObjects in that particular case scenario if you can use static variables. Do static variables make copies of themselves for each instance? Same goes for consts.
Yes, performance differences between static and SO is almost zero, check taradev video on this. But SO will allow game designers to easily tweak values, and it will be more easy for the designers to edit values in inspecter.
Is the stack and heap just a logical construct by the operating system or the compiler, because on a hardware level surely all the memory space is the same, their isn’t different types of memory cells in the memory sticks is there?
The second last advice is NOT right. Sometimes adding and removing a component is THE ONLY WAY to avoid it having an impact on other systems, even when diasabled, EXPECIALLY for a rigidbody!!! Absolutely not agree on that 🤔 ( Maybe to advice having 2 verions of the same object pooled, one with and one without the component .... that is good advice)
A must watch for every unity game developer! Thank you.
Thank you for watching, Jan! :)
@@ArturoNereu Super util. muchas gracias Arturo!
"We add empty functions Start and Update for you - just remove it"
- Unity
unnamer345 interesting, yes yes 😂
And you can make your own template to override that
unity just trolling us lol
@@solkar And I have to make my own template every single time whenever I want to update the Unity version
Hi. This series is something much needed, thanks a lot. With respect to the recommendation about using preprocessing directives to eliminate properties: I had the notion that this kind of simple properties were inlined by the compiler in non-editor, or at least non-debug, builds. Why do why need to use this kind of tricks? Are this kind of properties not usually inlined? What about using AgressiveInlining with the MethodImpl attribute, would that make them be inlined?
In normal .NET they would be inlined by JIT usually by default. No idea if Unity3D does something terrible such as removing inlining from JIT or something from their customized runtime.
A note for myself:
- Functions use the stack, fast, Class instances use the heap, be careful
- If you have lots of objects, use a scriptable object to save shared properties
- Choose the correct data structure
- Use object pooling, decide how big the pool is
- Properties (those with get and set) have an overhead, prefer just using fields aka variables, as shown here
- Use the addressable asset system, since the resources folder slown down load time
- Remove empty events when not using them
- Activate or instantiate objects after the first frame, sine you might have too much things on start() and awake()
- 22:33 When you change something using a string, compute the hash
- Avoid complex hierarchies in your scene tree
- Disable the accelerometer if not used
- Move rigid bodies with their methods in fixedUpdate()!
- Cache your references if you need to use thigns like Find()
Never thought that scriptable objects are can be used to save memory. Thank you for your kind effort!
Thank you! Yes, some of the benefits of SO's.
T.Y. this what I'm talking about. Useful uploads, big time.
Thank you, Carlos!
This is a great video! Absolutely everyone who writes code for Unity should watch it!
Thanks for your kind words, Anton.
@@ArturoNereu Thank you for the great video!
This is great, thank you for this. Please make more videos focusing on performance
UNITY IS GONNA REACH 1M SUBSCRIBERS !
What a fine explanation of stack and heap memory! Thank you for the good clarification. I m loving it.
A lot of these tips i knew were good practice but i didnt really understand *why* before watching this video. Thank you very much for the presentation 🙏
Great to read this! Main goal was to provide a bit of background on possible root of problems. Thanks for watching!
Awesome useful video. Have already watched tons of optimization videos before but some of tips were really new and useful. I need hundreds of such tips xD.
Please do in depth presentation for these with best practices! thank you.
Thank you! Will work on more in depth content!
Can you guys do one on physics optimization? I can't quite grasp what the performance hit of rotating a rigidbody's transform is.
Good idea, physics is a very interesting topic to cover.
Thanks for the video. Would it be possible to share the presentation? There are some really good examples.
Hello Chaitanya, of course. Here it is: docs.google.com/presentation/d/1A3MQJef-WzH1gE9pYOfQz8SeodBSE2sUJv8b1-PlXCA/edit?usp=sharing
I would like an in depth/ practical example of getter/setter optimization. How much up a real performance boost are we talking? Are we talking better memory management or reduce load?
It really depends. In most cases the real benefit will be close to zero. But just to provide an answer, the benefit is because without getters/setters you basically avoid calling another function.
yes, please !!
Super interesting video.
Unfortunately, certain subtleties of the English language have left some areas of fog ... This is why I thank you warmly for using a presentation, which made viewing easier.
I look forward to a sequel.
Hello Jean-Michel, yes. the subtitles are not the best (they are generated by UA-cam I think). Here's the presentation with the notes. Hope it helps docs.google.com/presentation/d/1A3MQJef-WzH1gE9pYOfQz8SeodBSE2sUJv8b1-PlXCA/edit?usp=sharing
@@ArturoNereu Thank you very much for the link, the presentation is more complete than the video. The graphics and audio tips are very interesting.
I have questions about slide 46 (audio import settings):
- on the slide, you mention Vorbis for Android: what is it about? To use in priority or not to use?
- in the notes, a Quick Guide to configure the audio settings is indicated, but I did not find the link. Could you tell me where to find it?
Is there an overhead of a complex hierarchy even if we don't define a method OnTransformChanged in our components ?
Isn't the matrix of a Transform flagged for recompute and only recomputed if we access it ?
Thanks a lot, this is fantastic tips!
Very useful Thank you!
While these are very basic tips, I don't quite understand the need for ScriptableObjects in that particular case scenario if you can use static variables. Do static variables make copies of themselves for each instance? Same goes for consts.
I think that in this case, while static might have the same memory usage, flexibility for changing them is better using SO.
@@ArturoNereu That didn't even cross my mind, I'm dumb.
Yes, performance differences between static and SO is almost zero, check taradev video on this. But SO will allow game designers to easily tweak values, and it will be more easy for the designers to edit values in inspecter.
That hashing part caught me offguard. ;w;
not sure if that was good or bad :)
I have a question about Transforming objects. If our rigidbody is kinematic, which class should I use to change position, Transform or Rigidbody?
Awesome
Thanks a lot, Leon!
thank
Aren't properties with no code automatically optimized by the IL2CPP pass & subsequent C++ optimisation ?
Why are you using new + destroy functions in GC example? Afaik It is never used this way. This example can confuse new unity learners.
Nice presentation 👍🏾
26:27 so if i want to rotate or move "RootGameObject" then it will affect gameobjecta and gameobjectb right ?
What is addressable assets?
Nice
Thank you, David!
Explain that you're a 'game evangelist' to my grandparents. I dare you.
Hahahahahahhahahahahahahahah 😅😭😅😂😂🤣🤣🤣 u left me dead .
*Instant slap by grandma*
Is the stack and heap just a logical construct by the operating system or the compiler, because on a hardware level surely all the memory space is the same, their isn’t different types of memory cells in the memory sticks is there?
Can we get a summary slide?
sure, here it is docs.google.com/presentation/d/1A3MQJef-WzH1gE9pYOfQz8SeodBSE2sUJv8b1-PlXCA/edit?usp=sharing
@@ArturoNereu Very helpful!
Thxxx
2:06 mounee? What's that?
Hey, sorry I meant "money".
The second last advice is NOT right.
Sometimes adding and removing a component is THE ONLY WAY to avoid it having an impact on other systems, even when diasabled, EXPECIALLY for a rigidbody!!!
Absolutely not agree on that 🤔
( Maybe to advice having 2 verions of the same object pooled, one with and one without the component .... that is good advice)
Good but basic stuff. I'd like to see more advanced tips regarding performances.
Nice