I want to have a callback function for when the UI needs to be disabled. Mainly because I want to let their own scripts have their own condition on when it becomes true. Hence, I made something like this:

IEnumerator HideUponActivation(Func<bool> activation) {
    yield return new WaitUntil { ()=> { return activation.Invoke(); } };

This code won't work because I'm getting two errors:

  1. Cannot initialize type 'WaitUntil' with a collection initializer because it does not implement 'System.Collections.IEnumerable
  2. There is no argument given that corresponds to the required formal parameter 'predicate' of 'WaitUntil.WaitUntil(Func)'.

I want this script that contains HideUponActivation(Func) to manage the condition of which it needs to hide the UI. I don't want to make use of all the other gameobjects to grab a reference of this script nor do I want to call the Singleton instance of this script. Is it possible?

  • \$\begingroup\$ Can you show this script in a bit more context, so we can fully understand how you intend it to work? As you've shown, this code doesn't compile, so it's difficult to reason about what it was meant to do. Try showing us where you start this coroutine, and what scripts are meant to be disabled/invoked by it. \$\endgroup\$ – DMGregory May 23 '20 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.