- Home /
Change InvokeRepeating in another script
My problem is that I use this script in 'Script_01';
var ScoreSkin:GUISkin;
static var s1lvl1Score: int;
InvokeRepeating("Add",0, 0.1);
function Add() {
s1lvl1Score += 1;
}
function OnGUI(){
GUI.skin = ScoreSkin;
GUI.Box(Rect(Screen.width*0.475,Screen.height*0.9,200,35), s1lvl1Score.ToString());
GUI.Label(Rect(Screen.width*0.375,Screen.height*0.9,200, 35), "SCORE :");
}
Now I want to change in 'Script_02' the InvokeRepeating of 'Script_02'.
This is my script in 'Script_02';
function OnTriggerEnter(other : Collider){
if (other.gameObject.CompareTag("CharTag")) {
//(CHANGE THE InvokeRepeating of 'Script_01'..)//
//into InvokeRepeating("Add",0, 0);//
}
}
Someone who can help me please? :D
EDIT
Please someone help
Answer by MissingSemicolon · Jun 14, 2013 at 12:13 PM
You might want to look into CancelInvoke:
http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.CancelInvoke.html
You could create two methods inside script01, one that will start the invoke and another to stop it.
One important thing to note, if you want to invoke the same method again but with different parameters to make sure you first cancel the old one, otherwise you will have two running at the same time.
In the start invoke method you can then pass in the parameters you want to change and call this from Script02.
Let me know if this helps.
I don't know how to cancel the invokeRepeating of an other script.
Script_01 has: InvokeRepeating(Add, 0, 0.1);
and in Script_02 I use: CancelInvoke("Add");
Can you help me out?