Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

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

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; }

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; }