Home c# How does UnityAction: Event System.action

How does UnityAction: Event System.action

Author

Date

Category

In Unity Docs found: https://docs.unity3d.com/scriptreference/ Events.UnityAction.html

It seems to be understood that it can store variables, and the type void .
But did not fully understand how it works, and can he do something else.
Here are these:

  • Event System.action
  • delegates

Answer 1, Authority 100%

Store variables and Void type

UnityAction – This is essentially a delegate (unityaction () , in general, void delegate ). If in simple, then columns. If you need to subscribe to some event, then here UNITYACTION and you should use.

In essence, in the example of the link, everything explains:

// Add a subscriber
M_MYFIRSTACTION + = MyFunction;
// Subscribe to the button Pressing the button
// When the button is pressed, all the subscribers from M_MYFIRSTICTION will receive a notification
m_addbutton.onclick.addlistener (M_MYFIRSTAction);

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions