I was just working on some project, and I got a scenario where the best solution to the problem I can think of was reflection.
It’s a part of a plugin I am making in Unity. There is a class I don’t want the user to mess around with, they should only use it to get references to instances I make for that class. There are a few members in the class that are not supposed to be accessible by the user. So I made them private and used reflection to get them.
There is just one problem… I have heard reflection can be pretty slow. That it’s good to use it from things that are called from time to time, but the way I used it here is inside of a for loop (not a nested one, but still a loop), that’s inside of a function I expect the user to call pretty often (sometimes even every Update).
I found many people that talked about it online, but I am now asking specifically about GetField and GetProperty methods. Are they slow?