So, I’m trying to make a universal level save system, that you just drag and drop into a scene. For the most part it works, but it was suggested that I open it up to a bit of customization and allow for expansion and custom elements to be saved…
My question is, how can I, when reading the save file, read a string then find a variable on a class by that name?
Heres some pseudo-code of what I hoped would work, but didn’t (as I despairingly expected…):
int Count=0;
string[] sSplit = (xmlValue[Count]).Split(":" [0]);
(GameObject.GetComponent<(Split[0])>()).(sSplit[1]) = float.Parse(sSplit[2]);
xmlValue is assigned earlier as a similar split delineated using commas, but my question isn’t about xml reading and writing, I know how to do that, its about that last line:
- Can I feed GetComponent<>() a string like I am?
- Can I then say Componenet.(String) like I am to access a variable? (I assume not)
If not, then how?