- Home /
Need help (String)
Not sure if you can do this in Unity but what I'm trying to do is get the text string on one letter.
Like
The Cat Jump
How can I now get the C (in Cat)
So can I can paste it in here
var test: String = "C";
I'm not sure if I'm saying this right but that what I'm trying to do. PLZ HELP.
Answer by zharik86 · Jan 24, 2015 at 09:14 AM
In Javascript haven't concept char. Only CSharp. If I understsnd correct, you try get one char of string and save it to another variable:
void Start() {
string first = "The Cat Jump";
string test = first[4]; //view first string as array and get right char
}
I hope that it will help you.
Answer by tanoshimi · Jan 24, 2015 at 09:18 AM
Errr... what? You can retrieve a substring of any length from a string like this:
var original : String = "The Cat Jump";
// Get a substring of length 1, starting at position 4
var test: String = original.Substring(4, 1);
The variable test now has the string "C" in it. But iy our source input was "The Dog Jumps", it would be a "D" instead. I'm not quite sure how you want to identify which character you're grabbing...