This coding practice is to overload existing functions with customised capabilities
- It has to be static function
- The format as follows:
- Use IEnumerator when use Action
- "yield return null" is needed to continue the coroutine when condition is true
- call Action in the extension method
- 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");
})
)