- Home /
writing multiple strings to a string array in a (non componement) public class
I'm writing a code to trigger npc dialog and all that is left to do is to send the dialogue to a non componement file.
string[] sentences = new string[3] { "finally got it to work", "now i can go home", "and eat" };
dialouge.sentences = sentences;
dialouge is the public class im writing to
For some reason writing a single string does seem to work:
dialouge.names = GameObject.Find("MainCamera").GetComponent<RayPoiint>().objectName;
Debug.Log(dialouge.names);
Really hope someone here can help me out, since this super simple code has stumped me for several hours now
writing these strings to my other script doesn't work
string[] sentences = new string[3] { "finally got it to work", "now i can go home", "and eat" };
no errors, debugging just returns
System.String[]
Then, there is no error as far as I can tell, the console won't show the content of the array. Either loop through the array in order to log each entry, or use the following line since you have an array of strings
Debug.Log( string.Join(",", dialouge.sentences ) );
at first i used this code in my "public class dialouge", and filling it in at the inspector of unity worked(and still does).
public string[] sentences;
Now i want to automatically fill it in with scripts, wich has just been an absolute pain
Your answer
Follow this Question
Related Questions
.txt file to string[] brakes by line 1 0 Answers
Breaking up a string every A,B,C,D and store value behind it 3 Answers
Java List. 0 Answers
How Do I Convert String to String Array In List.Add? 1 Answer