I have a prefab of a "generic unit;" each one has a script with some public variables: name, health, and attack.
Currently, I am manually making copies of that prefab and editing their names, health and damage values in the inspector. This seems unwise to me.
I would rather be able to make a simple file for each unit type, containing its important information, like this:
name = "Archer" health = 3 attack = 1
And so on. Then, I would like to be able to turn that into actual GameObjects in Unity, presumably by instantiating the prefab and filling in its values with values from the file.
I could then make a script that runs when the game begins and iterates through, making all the objects I need.
However, I do not know the proper way to go about doing this. Is there some way to read files and slot values into variables of a script?
To be clear, I would like to be able to tell Unity to make an Archer, then have it read the Archer file, look up its values for health and attack, then instantiate a copy of the Generic Unit prefab and slot the values that it read into the public variables of a script component of the newly-created game object.