Question by 
               juhawilppu · Apr 23, 2017 at 04:09 PM · 
                c#invoke  
              
 
              Invoke with syntax checking (C#)
Let's say I'm calling Invoke for a function called Enable.
     Invoke("Enable", 2f);
 
               It works, but it is not very safe because it's string based. There is no compile time checking and it will only throw an exception during run-time if no such method exists. Is there any way to do this safely?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Hellium · Apr 23, 2017 at 04:09 PM
Yes, use coroutines
 // top of your code
 using System.Collections;
 
 // ...
 private IEnumerator Enable( float delay )
 {
      yield return new WaitForSeconds( delay ) ;
      // your code
 }
 
 private YourFunction()
 {
      StartCoroutine( Enable( 2f ) );
 }
 
              Your answer