string as variable to call variable in class

Hey :slight_smile:
I reduce this to one variable type (verts as Vector3), that there are not so much variables.

I have a Class “DataTiles” with all variables i need to safe. (I have a json and a binary formatter to safe this class, so i can choose like i need.)
Variables in this class example: Vector3 map0_0verts, Vector3 map0_1verts and so on. (actual 25 of them)
actual i safe the mapverts by need with:


next step i need 250 of them, perhaps anytime 2500 or more.

is there a way to use a string as the class and/or variable name to do more automatic like one of this 3 sure not working examples to explain what i look for?

if not, someone has an idea or a link to a better solution ?

Saving much Data is a Horror :frowning:

You can use reflection in c#, but I don’t think it’s a good idea, you may need to change the way you store data, maybe you can simply use arrays to store these data, and it’s more readable, just simply use data[ x + y * w] to read/write data without any additional cost. For very large tile data, you may want to check sparse array

hey thanks for the answer, my brain is back .)
i tried reflection yesterday after searching, but its really curious and not easy handleable.
Sparse Array looks nice, i must look there deeper next days.

i have found a solution for my problem, i use a Dictionary Vector2, Vector3 (or the needed type) for the data. not sure why i not found this easy way yesterday… (what you not can see on top, the middle is 0,0 but i have -5/-5 to +5/+5 incl. 0 so 11x11 fields.
first i tried to do d dictkey as int but with all this 0 around its more trouble as Vector2 what is clear with the position.

now some easy work in my json and binaryscripts but its better than this ugly variable use.

Thanks a lot for the inspiration.