Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

MonoBehaviour.CancelInvoke

Switch to Manual
public 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(projectile); instance.velocity = Random.insideUnitSphere * 5; }
public 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(projectile); instance.velocity = Random.insideUnitSphere * 5; }