MonoBehaviour.CancelInvoke Manual     Reference     Scripting  
Scripting > Runtime Classes > MonoBehaviour
MonoBehaviour.CancelInvoke

function CancelInvoke () : void

Description

Cancels all Invoke calls on this MonoBehaviour.

// Starting in 2 seconds.
// a projectile will be launched every 0.3 seconds
var projectile : Rigidbody;
InvokeRepeating("LaunchProjectile", 2, 0.3);

// Cancels the repeating invoke call,
// when the user pressed the ctrl button
function Update() {
if (Input.GetButton ("Fire1")) {
CancelInvoke();
}
}

function LaunchProjectile () {
instance = Instantiate(prefab);
instance.velocity = Random.insideUnitSphere * 5;
}

function CancelInvoke (methodName : string) : void

Description

Cancels all Invoke calls with name methodName on this behaviour.

// Starting in 2 seconds.
// a projectile will be launched every 0.3 seconds
var projectile : Rigidbody;
InvokeRepeating("LaunchProjectile", 2, 0.3);

// Cancels the repeating invoke call,
// when the user pressed the ctrl button
function Update() {
if (Input.GetButton ("Fire1")) {
CancelInvoke("LaunchProjectile");
}
}

function LaunchProjectile () {
instance = Instantiate(prefab);
instance.velocity = Random.insideUnitSphere * 5;
}