Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.
You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.
What’s the purpose of the nextLeters
array? And have you already watched lecture “For Loops” in the Text Adventure section in the Unity 2D course? Depending on what your goal is, Rick’s solution could be more efficient.
Theoretically, if all you want to do is to display a glyph which is associated with a key, and if the KeyCode matches the glyph, you could use the ToString method of the KeyCode enum and Input.anyKeyDown. If the glyphs don’t match the KeyCodes, you need to map them manually like you did with your nextLeters
array. An alternative would be a dictionary, where you look up the current pressed key.
As aforementioned, if you have a pattern, you can easily have the computer do the job for you. If you don’t have a pattern, you will have to do everything by yourself.
Hope this helps
See also;