- Home /
Question by
NinjaRubberBand · Sep 06, 2016 at 02:43 PM ·
texturetextcharacter
Find position of character in text
In my script i have a public text, and a variable which shows how many characters that text has. It looks like this: public int charsInText; public Text textToWrite; void Start () {
charsInText = textToWrite.text.Length;
}
How can find a specific character in the text by number? Some pseudo coding as example:
text.findCharacter[4]
so the 4 character is chosen.
Comment
Answer by hexagonius · Sep 06, 2016 at 03:18 PM
since text is a string with indexer, you can just index it directly:
text[3]
I case of the word "test" it would give you the last "t". Remember, that indexing starts at 0, the first character
Your answer
![](https://koobas.hobune.stream/wayback/20220612092300im_/https://answers.unity.com/themes/thub/images/avi.jpg)