- Home /
Question by
Raizekas · Mar 27, 2014 at 05:34 PM ·
functionvalueparameters
Unityscript how to change parameters value
Hey, is there any way to change parameter's value by executing function? I have this code:
function ReadLineFromFile(sr : StreamReader, line : String)
{
line = sr.ReadLine();
}
Yet it only changes the function's variable "line". If I'd Debug in function, everything would seem fine, but if I'd use the "line" variable outside the function, it'd be just null. Is it posible in UnityScript to change parameter's value, for example, in c++ I'd just add & symbol near the variable, but how is it done in UnityScript?
Edit: Oh, by the way, I don't want to use "return"
Comment
Best Answer
Answer by perchik · Mar 27, 2014 at 05:40 PM
Since I can't come up with any logical reason why you don't want to use return and there's no way to use reference variables in UnityScript, I'm going to tell you to use return.
function ReadLineFromFile(sr : StreamReader)
{
return sr.ReadLine();
}
function someOtherFunction()
{
var line:String = ReadLineFromFile(sr);
}