InvokeRepeating()

I have just stared down the wonderful road of InvokeRepeating methods. What I would like to know is; is there a easy way to toggle these methods on and off. For example lets say I have a class with

    InvokeRepeating("SpawnNewCharacter", 4, 4);
    InvokeRepeating("AddResource", 4, 4);

and I want the component to spawn new characters only when its not adding resources, and vice versa. I had thought about making one method that will spawn either or based on a toggle, but I know I will be extending this class and adding other possible actions.

You can use CancelInvoke where necessary, but it sounds like coroutines would be more appropriate for this than InvokeRepeating.

private var addingResource : boolean;

function Loop () {
    while (true) {
        yield SpawnNewCharacter(4.0);
        yield AddResource(4.0);
    }
}

function SpawnNewCharacter (delay : float) {
    while (!addingResource) {
        Instantiate(character); 
        yield WaitForSeconds(delay);
    }
}

function AddResource (delay : float) {
    while (addingResource) {
        resources++;    
        yield WaitForSeconds(delay);
    }
}

In this case, setting "addingResource" to true or false toggles between the two functions.

http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.CancelInvoke.html Seems like you could do that easy enough