What are Events? (C# Basics)

What are Events? (C# Basics)

Code Monkey

4 года назад

375,908 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Valley Kid
Valley Kid - 16.10.2023 00:40

Why is there so much emphasis on the key strokes? It's like listing to a person chew a banana.

Ответить
Robson
Robson - 05.10.2023 03:15

This one i found kinda hard to understand. I watched the 4 hour video of C# from freecodecamp just to prepare for your unity course and i felt dumb because i can't really garsp the events subjects from this video...

Ответить
Inami Lanzhu
Inami Lanzhu - 23.09.2023 12:14

thankyou, it's super clear especially after watching the delegates tutorial

Ответить
K Stevenson
K Stevenson - 20.09.2023 05:25

So many videos make this complicated. (Some additional syntax might be helpful for those of us who see examples in ohter syntax, but this is so simple and easy to understand.) You made this seem way too easy. SMH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I've watched so many videos that try to take you through the event/delegate encyclopedia! Its overwhelming. I'm so refreshed. Thanks!

Ответить
Chuck Greene
Chuck Greene - 15.09.2023 16:50

Rather than including the entire System namespace, is there a way to just include the event part of it?

Ответить
Guido Skerianz
Guido Skerianz - 08.09.2023 20:29

What do you mean with "match the signature"?

Ответить
錘哥雜談
錘哥雜談 - 30.08.2023 18:42

I really like your courses, but there are a few issues: 1. There was an error when importing the Asset downloaded from the UNITY store, and it needs to be fixed. 2. The Assets do not have basic scripts for movement, should I find them in the tutorials or write them myself? 3. There are quite a lot of tutorials and I don't know where to start - either because I can't find the Assets or they don't match with the tutorials, or because I'm unsure which tutorial to begin with. These are some concerns that I have as a beginner watching your videos.

Ответить
Winter Caesaria
Winter Caesaria - 21.08.2023 00:01

Thank you so much for explaining this. After so long I've finally understood this.

Ответить
Burak Cenk Adalan
Burak Cenk Adalan - 20.08.2023 21:33

solid explanation and clear way, thank you !

Ответить
Krishna Singh
Krishna Singh - 16.08.2023 20:06

idk why but it's giving me error on the 'using UnityEngine ' and 'MonoBehavior' saying this type of namespace could not be found!!

Ответить
Zitong Wu
Zitong Wu - 10.08.2023 23:11

Hi, I'm getting "event must be of delegate type" when I use public event EventHandler myEventHandler. How to fix this?

Ответить
Kopil Kaiser
Kopil Kaiser - 09.08.2023 03:23

Great tutorial. I was able to learn all the concept pointed and taught on this video.

Ответить
jo jo
jo jo - 03.08.2023 18:31

thanks you very much! you are my hero!!!

Ответить
yash shiwankar
yash shiwankar - 30.07.2023 10:33

if start method runs only once and after that update starts to run then how can you subscribe to an event that fires off in update method and listen to it in the start method. I am really confused

Ответить
Danny Liang
Danny Liang - 20.07.2023 04:04

Can I just use "public event EventHandler<int> OnSpacePressed;" instead of defining another class as you did in the video?

Ответить
Eugene Ivanov
Eugene Ivanov - 15.07.2023 13:56

Is this Observer Design Pattern?

Ответить
BlackRaven
BlackRaven - 10.07.2023 16:53

I've been procrastinating events and delegates for a long time and never really understood, but you somehow manage to explain it so I can easily understand. I thank you for that!

Ответить
EVC AR Solutions
EVC AR Solutions - 02.07.2023 12:18

Hi Thanks for this beautiful explanation. I have a doubt , say i have declared a event like following

public event OnSpacedelegate OnSpaceDelegateEvent;

public delegate void OnSpacedelegate();

Now the things I can do with this event is
1.) Invoking the event (in same class or outside the class) - OnSpaceDelegateEvent?.Invoke();
2.) Subscribing to the event - testingEventPublisher.OnSpaceDelegateEvent += TestingDelegatefunc;

These things I can do without using event also like following

public OnSpacedelegate OnSpaceDelegateEvent;
public delegate void OnSpacedelegate();

Then what is the point or need of using the event. If there is any use with it , at what scenarios I should use it.

When I asked chatgpt , it was specifying that if we use event then that particular event cannot be invoked from outside the class which gives encapsulation.

But i have used event and tried to invoke it from other class , it was possible. Please try to give some clarity on this.

Ответить
bathtubanarchy
bathtubanarchy - 12.06.2023 04:44

I just finished Unity's Junior Programmer pathway and I really wish I'd watched this video about halfway through. My projects were always collapsing under their own weight towards the end, because something wouldn't work quite how I expected, which would mean I'd have to change one thing and then have to change everything that came before it to accommodate that change.

Ответить
Brandon Reames
Brandon Reames - 30.05.2023 03:41

Aside from visibility of events in the editor (with unity events), are there any reason to not exclusively use unity events?

Ответить
ThargUK
ThargUK - 23.05.2023 09:44

I've come here on a tangent from approx 3 hours into the beginners 2023 vid. I have 2 qs at this stage that may be answered later. 1 / in the 2023 vid you say something about events being better to use for stuff that is not every frame (e.g. interacting with counter instead of a key press) and I think you implied that an event is less work, not being checked every frame. Is this somehow magically true in the background (compiled, running code)? I get the code separation etc. but I would imagine that there is still a condition being checked every frame somewhere when it runs ...? 2/ It seems like there's no reason not to alweays use Unity Events, intead of delegates or "normal" events. Is this a "safe" assumption until I have the skill to ask much deeper questions? Do unity events and normal events "compile away" to the same thing? Thanks!

Ответить
Tigran Avagyan
Tigran Avagyan - 20.05.2023 17:44

Thank you very much for this video!!!

Ответить
Mikhail Humphries
Mikhail Humphries - 16.05.2023 22:49

What's the difference between Delegate and event?

Ответить
Averoes Ciare
Averoes Ciare - 02.05.2023 03:26

Great video. You know sometimes I imagine Code Monkey typing with his tung out like the avatar.

Ответить
JT Botha
JT Botha - 26.04.2023 22:16

Hi maybe I am just missing something stupid but at the very beginning of the code when declaring the Eventhandler I am getting a error saying that the event must be of a delegate type. Any advice?

Ответить
Roy Gatz
Roy Gatz - 22.04.2023 19:41

This is really the essential part to build a game. This should deserve more attention. Great job done!

Ответить
Максим Пунько
Максим Пунько - 19.04.2023 19:06

funny. I brute force my first project in unity without any knowlage, using GPT-3. And he suggest use SendMassege function, while argument accept string that is name of function that will be executed on another classes. And here best solution for this.

Ответить
林明信
林明信 - 18.04.2023 16:51

Thx, this ez and samiple to know

Ответить
adhochero
adhochero - 07.04.2023 00:01

i've used unityEvents before the eventHandler is new to me. threw me off while doing your course, I was like "I know events... not these events!" lol

Ответить
Skinner Space
Skinner Space - 02.04.2023 18:03

Nice lesson, I've been using events for a while but I just get stuck with Actions only and never even considered other ways of implementing this kind of observer pattern. Now I'm gonna try all of them and decide in which cases some of them are more convenient than others. Thanks!

Ответить
Minir
Minir - 12.03.2023 19:49

How do you use events when you want to fire them off from prefabs?

Ответить
John Doe
John Doe - 12.03.2023 00:51

Concise but fully and simple explained, I like that, you really have talent !............THX !

Ответить
حمزة اليهري
حمزة اليهري - 11.03.2023 08:26

i don't understand anything

Ответить
SereDim
SereDim - 09.03.2023 00:48

best of all event tutorials, thanks

Ответить
Antoine R
Antoine R - 08.03.2023 17:05

Thank you !

Ответить
saleh torkanloo
saleh torkanloo - 07.03.2023 16:54

Hello , i don't understand what is difference between events and delegates?

Ответить
Arkl1te
Arkl1te - 14.02.2023 00:22

This also helps me with Godot, which also has C# support. Thank you!

Ответить
Vi Ma
Vi Ma - 12.02.2023 18:20

I don't get the difference between events and delegates. I mean, i don't see the purpouse of declearing and event on the publisher since we could do exactly the same thing with delegates. Am i wrong?

Ответить
Zukusei
Zukusei - 07.02.2023 16:18

There is only ONE Code Monkey, legend !

Ответить
Keniseg
Keniseg - 06.02.2023 23:42

events would be really useful if you could subscribe without getting a component :/ bruh

Ответить
Chimz
Chimz - 05.02.2023 19:38

As a designer, having programmed at the bare minimum level to get my stuff working for nearly 2 years, watching your videos makes I realize I know nothing about coding xD

Thank you! These are very useful

Ответить
chaosmastermind
chaosmastermind - 03.02.2023 08:54

I'm going to have to watch this at least 5 more times to get it, but this is definitely the video to watch.
Events are super confusing.

Ответить
DOOMCHAD
DOOMCHAD - 02.02.2023 14:10

Hi Code Monkey! I am a beginner in programming and currently following your amazing FREE course.

can you do me a favor and recommend me some books that can help me increase my programming skills?
(books != Expensive)

Ответить
Joshua Hoem
Joshua Hoem - 26.01.2023 10:39

Why is it that when I did the exact same code, I got an error saying that the line "public event EventHandler OnSpacePressed" needed to be a delegate type?

Ответить
mostlyokay
mostlyokay - 10.01.2023 01:26

How do I find the GameObject that published the event if it's not the same that contains the subscriber? And worse, if it's spawned after a certain point? Do I make it publish an event on creation, and have the original publisher be a subscriber to this other event (seems very much coupled so I guess not)

Ответить
Genjutsu Edits
Genjutsu Edits - 09.01.2023 02:28

Thank you, best events tutorial

Ответить