Extension methods with Action

This coding practice is to overload existing functions with customised capabilities

  1. It has to be static function
  2. The format as follows:
  3. Use IEnumerator when use Action
  4. "yield return null" is needed to continue the coroutine when condition is true
  5. call Action in the extension method
  6. NOTE the special syntax of using the action method

Example of extension method:

public static IEumerator functionName ( this InputParameter1 inputPrameter1, InputParameter2 inputParameter, Action onActionComplete ) {
//method details

while (someConditionIsTrue)
yield return null; //continue to run while condition remain true

onActionComplete(); //Call this action when done

}

Example of use extension method:

startCoroutine (
    functionName(firstParamenter, secondParamenter, ()=>{
    //action for onActionComplete, using debug.log as example
    Debug.log("The action is complete");
    })
)