- Home /
Return a string not Working in Unity
Hey, I just tested something and got over this one.
void Start ()
{
returnString();
}
public string returnString()
{
return "This is a string";
}
So actually this is not working ))), it will not put in the console a message with "This is a string".
is this true that not working like this way. I mean, you can print mess. only Of Debug and print. Or I have to import some library ?
Answer by DajBuzi · Jul 24, 2014 at 08:12 AM
Hello,
You're returning the string but not doing anything with it. use it like this:
void Start(){
Debug.Log( returnString() );
}
String by itself would not go to the console, You have to "point" objects to the console like in the example above.
Regards, M.Rogalski
Yeah, okey, thanks, that What I was doing with the code. ))
Answer by RedDevil · Jul 24, 2014 at 08:14 AM
If you want to return a string just declare a string variable and if you want to see the string in the console use either Debug.Log either print("bla bla string");
Your answer
Follow this Question
Related Questions
Console-like guitext, adding header line gives weird result 0 Answers
Print String 3 Answers
A node in a childnode? 1 Answer
Allocation Already Register 1 Answer
Unity Debug Console - I want to input things during Runtime 1 Answer