I have 2 scripts (Javascript, by the way), scriptA and scriptB. By searching in unity's answers forum, I learned how to call a function in scriptA that is inside scriptB. Like this:
ScriptA
var scriptB: ScriptB;
scriptB.Test();
ScriptB
function Test() {
//code
}
This code works fine, but i need a to call a function with inputs and outputs. For example, if I use this for ScriptA and ScriptB, I get an error:
ScriptA
var scriptB: ScriptB;
print(scriptB.Test(2,3));
ScriptB
function Test(a : int,b : int):int {
return a*b
}
I don't know what the problem is, and I can't find any help on google, unity community, or anywhere else. Can someone show me how to call a function from another script with inputs and outputs?
↧