Summary: Replacing repeated variables with an array for blog post Unity: Live Text Effects.
Whenever I encounter a new programming technique I try to go back to previous projects to test it out. Or in this case whenever I write crappy code I try to go back and refactor the code. In a way I know could be better. But only if I try to clean it would I know for sure. So here I try to use a list/array in C#. Coming from a C background, I didn’t think the syntax or structure would be any different.
Google to the rescue for finding the correct Array syntax for C#.
I left lazy for writing copy paste code on my last blog Unity: Live Text Effects. So here’s a cleaner version of that code using Arrays.

And now to replacing this copy paste crap with an Array/List.

The inspector looks better too. Plus you can add as many text areas as you like. Instead of just 3.

