in my program I have loads of text that is stored in sepperate String variables.
More often than not I have to have linebreaks to display the whole text.
The manual says that one should use “/n” to break lines but so far I have not been successfull at that…
this is what I do:
var avatarDialog = "this sure is a long line /n thank god for the line break";
Well, what are you doing with the string? Trying to log it? Display it through a GUI_Text object? Something else? The string likely isn’t the problem, it’s probably the receiver.
“doesn’t work” needs some serious details and clarification added to it.
What I am trying to do is use GUI_Text object to show text on screen.
following is an example of a string that I store in a “masterDialog” file.
var mamba_in_id3 = "Say what!!! A liposuction of a 1000 pounds!!!\n You saved my ass, sister, \ngo ahead and take those sneakers,\n soon I'll be able to walk and get my own!";
And the following is the how I get it on the screen:
if (state == 1){
dialogGui.guiText.text = dialog.amira_mamba_in_id1;
}
and this is how I get my masterDialogScript, which is basically a script that holds a bunch of string variables with the my dialog:
var dialog: masterDialogScript;
dialog = obMaster.GetComponent(masterDialogScript);
everything works fine except the linebreaks.
I hope I have made myself a bit more clear this time.
ahh… well didn´t notice I posted 2 different string names… but that does not matter… I have tried to break many of the strings…
for the record this is the amira_mamba_in_id3
var amira_mamba_in_id1 = "Amira from down the block";
this is the whole conversation:
var mamba_in_id1 = "Who's there?";
var mamba_in_id1_audio: AudioClip;
var amira_mamba_in_id1 = "Amira from down the block";
var amira_mamba_in_id2a = "1. Can I get those fat sneakers?";
var amira_mamba_in_id2b = "2. How do you get out of here?";
var amira_mamba_in_id2c = "3. What is your weight";
var mamba_in_id2a = "My fat pair of sneakers, the ones I won from the\nSSSBBBW\n(super-sized-sexy-big-black-beautiful-woman) \n contest. No way I'm saying, ya hear, no way! \n I might not be able to see them, \n but I know they're there and they're fly. \n Well.., if you can get me out of here I may consider";
var mamba_in_id2b = "You tell me, your skinny chocolate bar, \nI haven't been out since the SSSBBBW contest. \nIt took three cranes. Can you help me?";
var mamba_in_id2c = "At the SSSBBBW contest it was 1000 pounds.";
var mamba_in_id3 = "Say what!!! A liposuction of a 1000 pounds!!!\n You saved my ass, sister, \ngo ahead and take those sneakers,\n soon I'll be able to walk and get my own!";
var mamba_out_id4 = "I would like to order some food, for delivery please, 10 deep fried chickens and 6 bottles of coke. Thank you.";
var mamba_after_id5 = "Thank you sister";
as I said earlier, I can display the text but the \n doesnt seem to work …
It looks like you are thinking that editing the values in the script will update the ones in the attached component.
Please note that the string at the left of the assignment is only setting the default value for the variable. It will not change if the script has already been attached to a game object.
Either remove the MasterDialog script from you game object and reattach it or reset it in the context menu in the game object inspector.
FYI, I just ran into this problem. But for me the newlines were getting encoded into visible text. This may be because I was setting the string values directly from the inspector.