With the help of a certain function, I get all references to classes in the desired Gameobject .
Is it possible to get all the variables from this class without going through each class?
Unity3D is a toy creation engine => maximum performance is important.
What you describe is called reflexion, when an object moves through the bones to the extent that you can read and write protected properties, which reduces performance by several times due to the fact that metadata tables are being searched, and there is an active work with strings. . (See CLR VIA 4.5 from Richter).
And then on the pages of STEAM users will complain that the game slows down on CORE I9 and 1080TI :)
I suspect that you do not need it, but you need something else.
Create properties that allow you to read the data fields and you will be happy.
If you solve the problem of flexibility, then use interfaces or dependency injection.
Source: https://ru.stackoverflow.com/questions/774838/
All Articles
Type.GetFieldsand for the received fieldsFieldInfo.GetValue- yolosora