Callback from a Loop

How can I register a new callback each time a method is called in a loop?

Return a value from the called method or call a custom event, like this:

public static MyCallbackEvent onCallBack = new MyCallbackEvent();
public class MyCallbackEvent : UnityEvent<optionalType> {}

Remove the <> brackets if you do not want to pass a type.

Invoke the event:


Listen to the event:


public void CallbackListenerFunction(optional type)
// do stuff