What are Events? C Basics

📝 C# Basics to Advanced Playlist
🌍 Get my Complete Courses! ✅ ​
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games

✅ Let’s check out what are C# Events, how we can use them and how they help us keep our code nice and clean.
For example Events are excellent for separating Logic from Visuals. Recently I made a video covering a Skill Tree and in it I used the same Level System I made months ago but with a different visual interface.

Learn Unity in 17 MINUTES!

Learn C# BASICS in 10 MINUTES!

What are Events? (C# Basics)

What are Delegates? (C# Basics, Lambda, Action, Func)

What are Interfaces? (C# Basics)

What are Generics? (C# Basics)

What are Loops? (C# Basics, for, while, do)

Unity Tips in 10 MINUTES!

Unity Basics for Beginners

Level System in Unity

Simple Skill Tree in Unity (Unlock Abilities, Talents)

If you have any questions post them in the comments and I’ll do my best to answer them.

🔔 Subscribe for more Unity Tutorials

See you next time!

📍 Support on Patreon
🤖 Join the Community Discord
📦 Grab the Game Bundle at
📝 Get the Code Monkey Utilities at

#unitytutorial #unity3d #unity2d

——————————————————————–

Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.

I’ve been developing games for several years with 7 published games on Steam and now I’m sharing my knowledge to help you on your own game development journey.

You can see my games at www.endlessloopstudios.com

——————————————————————–

– Website:
– Twitter:
– Facebook:

C Events – Creating and Consuming Events in Your Application
C Events - Creating and Consuming Events in Your Application

You almost certainly know what events are in C#. Even if you do not, you've probably used them before. What Read more

C Events and Delegates Made Simple | Mosh
C Events and Delegates Made Simple | Mosh

🔥Get the COMPLETE course (75% OFF - LIMITED TIME): Want to learn more from me? Check out these links: Courses: Read more

GTA 5 – All Random Events
GTA 5 - All Random Events

Walkthrough / Guide for all the 57 Random Events to complete in Grand Theft Auto V (HD) Watch all the Read more

Top 10 Craziest Events Caught Live on TV
Top 10 Craziest Events Caught Live on TV

Many witnessed these unforgettable events in real-time thanks to the magic of broadcasting. Join www.WatchMojo.com as we count down our Read more

20 comments

  1. 📝 C# Basics to Advanced Playlist
    🌐 Have you found the videos Helpful and Valuable?
    ❤️ Get my Courses or my Steam Games 🎮
    Here’s the highly requested C# Events video! This is one of the most important things to know about C# in order to keep your code nice and clean.
    🎮 Play 7 Awesome Games (Action, Strategy, Management) and Help Support the Channel!

    ✅ Get the Game Bundle 67% off

  2. I didn’t quite understand one thing;
    At the beginning of the video, it is mentioned that an event does not know or care if it has any subscribers, but at 4:25 it throws a null reference exception because we do not have any subscribers. Can anyone explain this, please?

  3. Correct me If I am wrong but plain events like shown in the video are still a tightly coupled system since you use a particular event name in your code to subscribe and listen to events. In this case, you use “on SpacePressed”, if you change that event in the publisher – all the listeners with that code won’t work. Also for adding listeners, if you are getting a direct reference to the event publisher to subscribe that defeats the whole principle of decoupling, you might have as well not used events at all and just do a direct function call.
    In my opinion a truly decoupled event-driven system would be a pubsub pattern, where you publish messages under a specific topic and a payload and other listeners can subscribe to the topic (without knowing a particular event name, only the name of the topic)

  4. Thank you so much, made this so easy and clear! So is it always a function that subscribes to the event, or can it be something else?

  5. Excellent Tutorial, but What different between these 4 type event method? I dont understand.

  6. Out of all the youtube videos I have seen so far this has the best “event” explanation. Thanks a lot.
    Edit: after further study I found the following: you also don’t want the subscribers to know about or interfere with the other subscribers. Events main job is to prevent interaction between subscribers by only allowing access to the event using just the += and -= (add/ remove)accessors, but the event needs to be placed inside of a type to make this possible. (typically in an EventHandler class/delegate or in an EventArgs subclass.) If you removed the event keyword the event would act like a normal delegate and it would allow subscribers to interact with each other by allowing any one of them to actually change the delegate( meaning the subscribe could now change the delegates internal values or even set it to null…which would be a bad thing.) Personally I don’t think events are simple to learn. But he did help clear up a few things that were bothering me.

  7. Why would I bother creating a new class that is inherited from EventArgs just to pass parameters, whereas I can simply use Action<> or a custom created delegate? No intention of objecting, just cannot see the point and very curious. Thanks.

  8. Events is really the most fucked principle, what’s difference between Delegates, Action, Events ? ONLY GOD KNOWS

  9. I love these videos, they’re so helpful! But in the intro, it always sounds to me like you’re saying “inept tutorials” instead of “in-depth tutorials” lol

  10. Great video thanks but one question, does events work with prefabs, because I am trying to fire up an event on ontriggerenter to damage the enemy when a bullet hit him but it’s not working, no errors

  11. Great video thanks! Just one thing, can you try to type a little bit faster?