I’ve asked (almost) this question before: How do i declare an event listener? - Unity Answers
I got some answers, the first one was to just make it static, which i went with and which worked up until now. Now i have a specific need for a per-instance event.
I got another answer there, from CHPedersen which explains how to do this non-statically, but frankly i just don’t understand it. I cannot get it working. So can someone please explain this to me again and/or in more detail.
Here is what i have so far:
Declaring the event
public delegate void DestinationEventHandler();
public event DestinationEventHandler DestinationChanged;
Creating a listener to the event, using a reference (creature) to an instance of the class which contains the above code.
creature.DestinationChanged += new creature.DestinationEventHandler(ReadPath);
This second part does not compile. I don’t understand why.
The example in the linked page, the only difference i could understand was the inclusion of “EventArgs e” in the handler. I don’t know what that is, and it won’t compile if i try to use it. Is that necessary?
One other difference i noticed is: “buffer_OnDataProcessed;” in the example, i don’t understand the use of an underscore there, and attempting to do the same for me doesn’t compile either.
I’m stuck, pls help ;-;