I assume this is the correct place to post this, just have a general C# question. Can you have an event do a callback?
For example can we have this;
void Start()
{
FindSomething("this is the thing to find", () => { Debug.Log("This should be called last"); });
}
void FindSomething(string value, System.Action OnComplete)
{
SomeStaticClass.DoThisMethod(value).onComplete += (EventMethod) =>
{
Debug.Log("This should be called second");
OnComplete();
}; // this makes the debug.log print "This should be called second" and then "This should be called last" but doesn't call the EventMethod() below at all.
}
void EventMethod(string result, System.Action OnComplete)
{
Debug.Log("This should be called first");
// do something with the result string
OnComplete();
}
Now before you ask why can’t I just do a callback with the DoThisMethod() like the others is because the SomeStaticClass belongs to another asset store product and I don’t want to have to rewrite all their code for this to work.