These 2 tutorials are EXCELLENT. Short, correct, to the point, and well informed. I know how to use delegates and events, but wanted to watch them anyway; you understand coding principles, and I'm really happy that you're explaining them to people, in the best way even! Just telling someone to "prefer" events, is useless, he does not understand where and when to use them; explaining which problems they solve is much more effective. Great job.
"Just telling someone to "prefer" events, is useless," ... I totally agree! I've been watching so many videos that just use events and don't explain what they're actually doing. Worse yet, they are using them when they don't need them by conjuring up redundant examples, like where one would never actually use an event in a real project.
i think this is the best video in the world to understand the concept of delegates, event, action and func. It seem so natural. Anyone who wants to learn about this concept in any programming language is welcomed here
Just a note, Unity recommended practice is to handle event subscription in the OnEnable() method instead of Start() (and unsubscribe in OnDisable()). This is to ensure consistent behavior if you disable+re-enable or destroy the game object later.
I can't believe I watched so many confusing videos before this and started to think I'm dumb ... and then 14 minutes from 6 years ago immediately made everything crystal clear. Thank you.
I am watching a lot of Unity tutorials for about 8 months, free and paid tuts, but yours are the best, because you cover information not just about basics, which is the most problem of other youtubers. Great job!
Many other videos on the subject over-complicate things without explaining how, when and why to use Delegates, Events, Actions and Funcs. You were able to explain all of these things clearly in less than 20 minutes. Well done, and thank you!
One of the best tutorials I found about delegates and events. Short, clear, straight to the point, and with awesome bonus tips about Action and Func. Thanks!
"Create the func!" Still trying to get my head around a good working example of when this is really useful to do, versus other techniques. But this definitely helped! :D
You proved that most of other tutorials makers about events in c# do not understand what they are trying to explain to, I thought the events topic was complex but now thanks to you Sebastian I know their explaining methods are complex
I want to further stress the point of how excellent, clear and straight to the point this tutorial is. I've watched 2 more before this and still had questions that were really quickly answered by yours. Thank you very much for the awesome content Sebastian!
For years I struggled to understand what is delegates and events, why to use them and when to use them... But these two videos have helped me finally understand what exactly they do and when to use... Thanks a ton for such amazing videos!!!
this is incredibly helpful. I've been looking at some online resources about actions, events, delegates and such. This is the only one I've seen that really clarifies the fact that the "event" keyword is NOT A TYPE. It is a keyword applied to a delegate. Thank you!
Sorry this is two years later but, is this a functionality only for delegates or could one use it in a different capacity? Consider: Target target = GetComponent(); target?.enabled = false; //instead of below Target target = GetComponent(); if (target != null) target.enabled = false; Any idea where I could read up on this? Tried Googling for a while but couldn't figure out how to phrase the search. Thanks.
@@garbage_person Yes, that is valid. This is called the "null-conditional operator", which you can read about in the Microsoft C# Programming Guide documents. Here is a link to the specific section: docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/member-access-operators#null-conditional-operators--and-
thank you so much, i watched lots of tutorials about events and delegates, and you are the only one who actually showed them in a simple and pratical way
Love it, expressing how and 'why' we should write code the right way. The way that saves us trouble. Lovely demonstration of SRP - This is the best example i have seen in why and how to use events. I'm book marking this to show my minions at work! Great job!
This is the best explanation I have heard so far about Events, I used them by following other people tutorial but without knowing how to the explain its usage to myself, right now i just 3 mins in and it already made alot more sense.
I've struggled with these concepts quite a bit. These videos helped to make things clearer to me since they have the explanation followed by good examples of how to use them. Thank you so much for making these tutorials!
I like this little series, I feel that I wouldn’t really be able to learn this kind of thing directly most of the time (in other tutorials) so it’s nice to have these things addressed.
Fantastic tutorial. I'm learning Unity and hadn't been able to understand events until watching this video. Thank you so much, you earned yourself a sub.
Thank you, Sebastian. These tutorials were the most helpful and least confusing ways to learn delegates and events I've found over the past few days. Keep up the good work
I'll have to re-watch this about 10 times before it clicks but I have a feeling this video is going to make it click. I'll try do some small scenes to practice. Thankyou for these videos.
Honestly I've been struggling to understand delegates for years so didn't use them, but your tutorial helped me completely grasp it! thank you! I'm now using Godot which relys heavily on "signals" aka delegates, while also using c# I can use signals still, but C# delegates seem way more powerful. I can attach multiple voids to one for instance, while you need a signal per void.
Bruh... I've been trying to understand delegates and events for weeks, and you taught me in 15 minutes. Thank you so much, I'm looking for more amazing lessons from you.
Youve earned my Sub, been trying to wrap my head around this pattern for a bit now. Your video has been very precise. Thank you, I am still struggling to understand it and will need to put it in practice to see its full effect.
Thank you so much!!! I'm was working on some stuff, had help from an alumni at school for thesis and I can finally grasp and write delegates and events. Bless you!
Quite informative and easy to understand because it wasn't as convoluted as the delegate video , so yeah I finally understand how to actually implement events, at least on a surface level, good enough for now. My advice is to strip the code as much as possible, no returns, no arguments at least in the first example, then step it up if you want.
To anyone who is interested, there is something called a UnityAction under the UnityEngine.Events namespace that also functions as a void delegate. You can read about them here: docs.unity3d.com/ScriptReference/Events.UnityAction.html
So basically, we are moving the reference, which is still required (just a different one), form the player to the Achievement and UI classes. I don't understand how this makes it any cleaner.
This makes it cleaner because it is responsibility of Achievement and UI to do something when player dies. So why Player should call functions in other classes?
Hi everyone, I hope this 2-part series has helped you get to grips with delegates and events. Let me know what topics you'd like to see covered in the future. If you want to translate this video, you can do so here: ruclips.net/user/timedtext_video?ref=share&v=TdiN18PR4zk
I doubt I am the only one who didn't quite understand threading in your terrain tutorials so I think people would like to see callback functions and anything similar to that covered.
+Purple Ice Well the callback there is just passing a method into another method, so it's using delegates like last episode. But I do think a video on threading in Unity is a great idea, thanks for the suggestion.
Well I just proved my point that I have no idea about anything related to threading, maybe I am just bad at googling but didn't find anything that would explain it to me, anyway, thanks for considering making a video on it.
Good thing you included the explanations for Actions and Funcs, they've somehow eluded me up to this point and should come in handy for several occasions. Thumbs up for a separate threading video, it's something I reckon many people would love to understand better since it's a powerful but tricky technique to get working right.
Devastus The problem is, almost everyone knows how it works in general after like 5 minutes of googling, but mastering is hard, and not something you can learn in few days. I don't even know where to start. I know that it works separately from main thread, that two threads accessing same thing at the same time can destroy everything and etc, but I have no idea where to start with them. I have followed simple tutorial on "voxel engine" on unity and the last thing I need for it to add whatever I want to it is threading so it stops freezing once in a while and I will be good to go, though I couldn't find ELI5 type of explanation for it so I gave up on that and moved on, for now. Anyway I will start going to university this year so I will learn it either way.
we need a 3rd tutorial for events with actions ,examples on how to use them , like theplayer,ui, that you gave on this one please when u have time it would be nice
These 2 tutorials are EXCELLENT. Short, correct, to the point, and well informed. I know how to use delegates and events, but wanted to watch them anyway; you understand coding principles, and I'm really happy that you're explaining them to people, in the best way even! Just telling someone to "prefer" events, is useless, he does not understand where and when to use them; explaining which problems they solve is much more effective. Great job.
Thank you!
This exactly, i wanted to write something similar, but i am not at all surprised that other viewers agree. Very informative tutorials!
"Just telling someone to "prefer" events, is useless," ... I totally agree! I've been watching so many videos that just use events and don't explain what they're actually doing. Worse yet, they are using them when they don't need them by conjuring up redundant examples, like where one would never actually use an event in a real project.
This is by far the best video I've seen on delegates events. I really love that real life example. Thank you for good content.
i think this is the best video in the world to understand the concept of delegates, event, action and func. It seem so natural. Anyone who wants to learn about this concept in any programming language is welcomed here
Just a note, Unity recommended practice is to handle event subscription in the OnEnable() method instead of Start() (and unsubscribe in OnDisable()). This is to ensure consistent behavior if you disable+re-enable or destroy the game object later.
Thank you
I can't believe I watched so many confusing videos before this and started to think I'm dumb ... and then 14 minutes from 6 years ago immediately made everything crystal clear. Thank you.
0:17 that went dark real quick i love it
I am watching a lot of Unity tutorials for about 8 months, free and paid tuts, but yours are the best, because you cover information not just about basics, which is the most problem of other youtubers. Great job!
Many other videos on the subject over-complicate things without explaining how, when and why to use Delegates, Events, Actions and Funcs.
You were able to explain all of these things clearly in less than 20 minutes.
Well done, and thank you!
One of the best tutorials I found about delegates and events. Short, clear, straight to the point, and with awesome bonus tips about Action and Func. Thanks!
Best tutorial on delegates around. Cheers Sebastian :)
You are a very gifted individual Sebastian Lague
"Create the func!"
Still trying to get my head around a good working example of when this is really useful to do, versus other techniques.
But this definitely helped! :D
I have seen a lot of tutorials (by a lot I mean by the hundreds) and this is one of the best tutorials I have ever seen. ty!
You are a legend, I am getting amazed every time I watch one of your videos.
You proved that most of other tutorials makers about events in c# do not understand what they are trying to explain to, I thought the events topic was complex but now thanks to you Sebastian I know their explaining methods are complex
I want to further stress the point of how excellent, clear and straight to the point this tutorial is. I've watched 2 more before this and still had questions that were really quickly answered by yours. Thank you very much for the awesome content Sebastian!
For years I struggled to understand what is delegates and events, why to use them and when to use them... But these two videos have helped me finally understand what exactly they do and when to use... Thanks a ton for such amazing videos!!!
I have found it difficult to understand and implement these concepts but luckily I was able to understand much better with these videos. Thank you!
I come here once a month to refresh the details between delegates/actions/funcs, and I have to say, thank you so much :)
this is incredibly helpful. I've been looking at some online resources about actions, events, delegates and such. This is the only one I've seen that really clarifies the fact that the "event" keyword is NOT A TYPE. It is a keyword applied to a delegate. Thank you!
As a noob game dev, this really helped me understand these intimidating concepts. Thank you so much Sebastian.
2:32 now you can do deathEvent?.Invoke(); instead of checking null with if.
Sorry this is two years later but, is this a functionality only for delegates or could one use it in a different capacity?
Consider:
Target target = GetComponent();
target?.enabled = false;
//instead of below
Target target = GetComponent();
if (target != null)
target.enabled = false;
Any idea where I could read up on this? Tried Googling for a while but couldn't figure out how to phrase the search.
Thanks.
@@garbage_person Yes, that is valid. This is called the "null-conditional operator", which you can read about in the Microsoft C# Programming Guide documents. Here is a link to the specific section: docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/member-access-operators#null-conditional-operators--and-
@@imSoCalamari awesome. Thanks so much for the info.
@@garbage_person yah it basically helps you check if the object is not null before calling a method from it, or getting an attribute from it.
This is called Null-conditional operators (?.) if anyone wants to look it up, it's available in C# 6 and later.
thank you so much, i watched lots of tutorials about events and delegates, and you are the only one who actually showed them in a simple and pratical way
Thanks much! I watched several videos and documentation, but never fully understood how to use delegates and Events until this vid. Thanks again.
Can't say enough how this tutorial is so much better than all the other c# event tutorials I've seen on YT.
Sebastian Lague, i learn so much in your vids... Thank you!
This made me understand delegates better than any resource i've studied. This deserves more views!
Love it, expressing how and 'why' we should write code the right way. The way that saves us trouble. Lovely demonstration of SRP - This is the best example i have seen in why and how to use events. I'm book marking this to show my minions at work! Great job!
This is the best explanation I have heard so far about Events, I used them by following other people tutorial but without knowing how to the explain its usage to myself, right now i just 3 mins in and it already made alot more sense.
The most excellent coverage on this topic. Thank you!!!
I was struggling for 2 days to figure out delegates and events, these two videos finally made it all click!
I've struggled with these concepts quite a bit. These videos helped to make things clearer to me since they have the explanation followed by good examples of how to use them.
Thank you so much for making these tutorials!
+J Herlache I'm happy to have helped!
I like this little series, I feel that I wouldn’t really be able to learn this kind of thing directly most of the time (in other tutorials) so it’s nice to have these things addressed.
you are awesome bro, thank God that people like you exist on earth!
Man, this dude's tutorials are S tier, best I've found in a long time
Fantastic tutorial. I'm learning Unity and hadn't been able to understand events until watching this video. Thank you so much, you earned yourself a sub.
Thank you, Sebastian. These tutorials were the most helpful and least confusing ways to learn delegates and events I've found over the past few days. Keep up the good work
Best tutorials i have ever seen about coding
I'll have to re-watch this about 10 times before it clicks but I have a feeling this video is going to make it click. I'll try do some small scenes to practice. Thankyou for these videos.
WOW! It became clearer in 6 minutes than in one and a half hour of lecture at my university.
Thanks!
Six years on and this is a timeless classic =)
Honestly I've been struggling to understand delegates for years so didn't use them, but your tutorial helped me completely grasp it! thank you! I'm now using Godot which relys heavily on "signals" aka delegates, while also using c# I can use signals still, but C# delegates seem way more powerful. I can attach multiple voids to one for instance, while you need a signal per void.
Thanks for these very useful tutorials. It's a big luck to find something like this in the ocean of "lets make a cube" scrap.
I always come back to this video cause I always forget the details of events and actions, but this video is short, precise, and awesome.
Really nice way of laying out multiple scripts for the audience to follow!
Easily the best explanation about Delegates and Events. Thank you very much.
I could not understand events for the longest time! You are a god send! Make a Udemy course, the people will come! Thanks!
Bruh... I've been trying to understand delegates and events for weeks, and you taught me in 15 minutes. Thank you so much, I'm looking for more amazing lessons from you.
This has been saved my life at the past, and gave me the best understanding I've ever had from youtube tutorial.
Thank u
Holy Cow! I just completed a whole project that basically calls methods from and to other scripts! Lesson learnt!
Youve earned my Sub, been trying to wrap my head around this pattern for a bit now. Your video has been very precise. Thank you, I am still struggling to understand it and will need to put it in practice to see its full effect.
i wish all other youtubers can deliver information like you , thanks man
One of the best explanations in youtube
This tutorial is godlike.
Your videos are soooo incredibly good! Thank you!
Very Helpful, i finally see what all the different words are for (event, delegate, Action, Func)
Hands down best tutorial on delegates&events.
Loved it the way you explained why before how..
That was absolutely incredible Sebastian! Good job, love your videos.
Thank you so much!!! I'm was working on some stuff, had help from an alumni at school for thesis and I can finally grasp and write delegates and events. Bless you!
Quite informative and easy to understand because it wasn't as convoluted as the delegate video , so yeah I finally understand how to actually implement events, at least on a surface level, good enough for now.
My advice is to strip the code as much as possible, no returns, no arguments at least in the first example, then step it up if you want.
These tutorials are great. Especially the concrete examples. Thank you.
Best on the youtube tutorial easy simple with great example ....Loved it 😍😍
You are simply awesome Teacher...
That's the single, most well explained tutorial about delegate I've seen, thanks !
SO EXCITED TO SEE THIE VIDEO, You help me solve a big problem,THANK YOU!
Events are the best thing about coding its fun and easy to use and keep code clean
Brilliant. So clear; so helpful. Thank you.
Thanks for tutorial. feedback : Actions and Functions needs some example.
Best Regards,
Just wanted to say, I really appreciate your channel. Thank you.
"DeathDelegate" - works as an identifier but also as a metal song/band name
This is exactly what I wanted! Thanks man
Great stuff. I'd like another example to really help the concepts sink in, but I'll just get into unity and try it out myself
This tutorial explains delegates very well, thanks!
To anyone who is interested, there is something called a UnityAction under the UnityEngine.Events namespace that also functions as a void delegate.
You can read about them here: docs.unity3d.com/ScriptReference/Events.UnityAction.html
It is really,reaally helpful.I am searching a basic explanation for this subjects.So thank you a lot Sebastian :)
Thank you very much to use your time to explain this to everybody, you are so clear
This vid straight ballin fr fr
This was amazing! So beautifully explained. I have subscribed and will now binge :)
Thanks you so much for taking the time to make this!
Amazing tutorial, explained a complex system so clearly.
So basically, we are moving the reference, which is still required (just a different one), form the player to the Achievement and UI classes. I don't understand how this makes it any cleaner.
This makes it cleaner because it is responsibility of Achievement and UI to do something when player dies. So why Player should call functions in other classes?
You are a great nerd, keep up the gj
lmao that's a rather interesting way to compliment someone
You guys are so funny hahaha
@@roko567 What makes it interesting?
I've long known about Action and Func, it's nice to see how to do this without importing System:-)
Hi everyone, I hope this 2-part series has helped you get to grips with delegates and events.
Let me know what topics you'd like to see covered in the future.
If you want to translate this video, you can do so here: ruclips.net/user/timedtext_video?ref=share&v=TdiN18PR4zk
I doubt I am the only one who didn't quite understand threading in your terrain tutorials so I think people would like to see callback functions and anything similar to that covered.
+Purple Ice Well the callback there is just passing a method into another method, so it's using delegates like last episode. But I do think a video on threading in Unity is a great idea, thanks for the suggestion.
Well I just proved my point that I have no idea about anything related to threading, maybe I am just bad at googling but didn't find anything that would explain it to me, anyway, thanks for considering making a video on it.
Good thing you included the explanations for Actions and Funcs, they've somehow eluded me up to this point and should come in handy for several occasions.
Thumbs up for a separate threading video, it's something I reckon many people would love to understand better since it's a powerful but tricky technique to get working right.
Devastus The problem is, almost everyone knows how it works in general after like 5 minutes of googling, but mastering is hard, and not something you can learn in few days. I don't even know where to start.
I know that it works separately from main thread, that two threads accessing same thing at the same time can destroy everything and etc, but I have no idea where to start with them. I have followed simple tutorial on "voxel engine" on unity and the last thing I need for it to add whatever I want to it is threading so it stops freezing once in a while and I will be good to go, though I couldn't find ELI5 type of explanation for it so I gave up on that and moved on, for now. Anyway I will start going to university this year so I will learn it either way.
Great videos, a good follow up to this would be a video about UnityEvents and UnityAction.
UnityEvent and UnityAction can be serialized in the inspector. You may notice it on some UI components
I love creating the func
Nice type declaration
this is amazing, thank you so much
Very very awesome video.
Thank you !
thanks for the explaintion
Thank you
Very good. Thanks
Best explanation I found.
Really clear videos. Great job!
Because a like wasn't enough. Here is a token of my gratitude! :)
great job, still a great vdeo after all this time :))
Awesome 2-part series : )
Good One!
we need a 3rd tutorial for events with actions ,examples on how to use them , like theplayer,ui, that you gave on this one please when u have time it would be nice