5 ways to make your unity3d code faster

preview_player
Показать описание

Learn 5 ways to improve the performance of your Unity3D C# code.

0:00 - Intro
0:35 - Outline, Likes, & Course Info
1:04 - The Unity Profiler
6:44 - Unintentional Debug.Logging! (and a trick to disable them)
7:42 - Using LINQ in the wrong spots (and what LINQ is + why it's wrong 'sometimes')
11:03 - #1 BEGINNER TIP - Caching!
14:56 - Pooling (with some code examples)
19:41 - Final Thoughts
Рекомендации по теме
Комментарии
Автор

I added a queues/pools for all my projectiles ... went from 5 FPS to 35 FPS !! It was amazing to see just how many projectiles get spawned in a shooter game :) Now I need to add pools for effects.

kyleme
Автор

The way I help performance the most with my team that is really easy for the most part is to avoid Update() as much as possible (although you shouldn't completely do away with Update). Instead of checking every frame in Update() if something is done, add a delegate to the end of what you want to check, then use that to see if all your conditions are met. Will save a ton of checks every frame if done well.

GGFTV
Автор

This is exactly what I've been looking for, as usual you are the person to come to when stuck.

UnGaming-ehht
Автор

Thank you sir for so many great tips. Seriously these were actually some awesome tips and with the use of profiler, they became perfect. Lastly, the Camera.main one was my favorite one. I didn't know that and now I know what might be causing me issues in FPS in my current game as I am constantly using it in an update.

vivekgamedev
Автор

The pooling using Queue is something that i am astonished with. Always had a problem with making a decent enough pooling and just worked without it. But with this? Time to re-learn something! great video as always!

xhunterx
Автор

Congratulations for 100k and thank you Jason !

petrosaslanidis
Автор

One thing I usually use to avoid debug logs in the final build is to use the Conditional attribute in a method Log and call it.

The Conditional attribute indicates to compilers that a method call or attribute should be ignored unless a specified conditional compilation symbol is defined.

[Conditional("DEBUG")]
void Log(string msg) => Debug.Log(msg);

dmgiacomelli
Автор

Welcome back young Jason :)
200 thumbs up for putting timestamps in doobly-doo !

TesT
Автор

Excellent tips. I've been struggling with many of this issues at some point.

dspartan
Автор

I can't believe you taught Queues and I understood it in seconds! Every other place I searched made it a little too complicated.

lemetamax
Автор

Great video, thanks again. I'm going to look at your profile video now. I really want to get the most performance out of my game for a specific level I want to make.

mintydog
Автор

I've been your subscriber for a long time and usually do not post comments on videos, but I never forget to Like!

I want to let you know your hard work is appreciated and I thank you for that! It's not taken for granted! Even when I come today with experience, it's always fun to refresh the memory in your videos!

I don't know if you'll respond to this or not, but I would love to read how you are lately? How is your work as a member of the Phanteon development team progressing?

Wish you all the best!

divainsyoutube
Автор

Im in the Alpha stage and this really helps! Thankyou!

Qmansvendetta
Автор

wow, you are super clear and it was really helpful, thanks!

agnesecaglio
Автор

Thank you for the video
Looking forward to "Mad birds" part 2: The "right" way 😀
Almost 100k subs! Woohoo!

coryronald
Автор

One thing about deep profile is that it has a big impact on performance so it may give you more details into specific areas that are the problem but isn't a good look at whether you do have any problems.

friendofphi
Автор

Really useful mate. One question though, with regards to the GetComponent fix. Is there a solution for when we are trying to find active objects that are constantly changing, like number of people in a gym? Or do we just have to deal with that being in an update method?

ChronikSpartan
Автор

Hey Jason, great tips as usual! Talking about performance...have you been keeping an eye on the unity ecs developments? I saw you had a video a while ago, but do you think it matured a bit since then to warrant a followup video? Would be a great design/architecture video series?

cywizz
Автор

9:11 My quick tip is:
When comparing 2 UnityEngine.Object don't use == or != operators because Unity overrides them and uses native code.
Compare the HashCode of them, it is only an integers comparison and it is guaranteed to be unique.

sagiziv
Автор

Thank you for another helpful video!
In your videos I see you switching between Rider and Visual Studio a lot. Do you often use VS in your daily work or just for the videos?

Faygris