Hello Guys,
I want to enable all functions in my Java script, when the boolean is enabled.
The boolean get’s enabled trough an other Script via GetComponent.
Please help
sry for my bad english (Germany
)
Hello Guys,
I want to enable all functions in my Java script, when the boolean is enabled.
The boolean get’s enabled trough an other Script via GetComponent.
Please help
sry for my bad english (Germany
)
//assuming you already have
function MyWonderfulFunction(){
// my code here
}
//you would either do (for each function you want affected by the boolean)
function MyWonderfulFunction(){
if(myBoolean == false){ //or if(!myBoolean)
return; // exit this function if boolean is false
}
// my code here
}
// or
function MyWonderfulFunction(){
if(myBoolean){ // do my code if boolean is true
// my code here
}
}
sorry for my bad psuedo code… I like C#
Thank you ![]()
var doFunction : boolean;
function Update () {
if (doFunction) {
MyFunction ();
}
}
function MyFunction () {
//code here
}