First of all, i am a pretty much a newbie when it comes to Unity’s coding and other stuff like that, and this is the first time me ever coming to the answers section, so sorry in advance if i didnt ask something right or wrong. I’ve been making a little 2D RPG game to mostly learn about unity and everything like that. Let’s say, i already have wrote a lot of “code”, that contains values, strings, changing text, and etc, etc.
But i wrote it all without saving in mind, so of course, later i am trying to take a look at how to save/load content, and then i see, that in every single tutorial for save/load systems, people write the values into that code itself, with the [Serializeable] within it, so that of course, confused me a lot.
And now i am wondering, do i have to rewrite everything i wrote, just so my game can support loading/saving?
Let’s just take this for example… I have this:
public class TA_Player_Health_and_stuff : MonoBehaviour {
public TA_Player_Scripts playerScripts;
int playerHealth = 100;
int playerHealthLimit = 100;
int playerHunger = 0;
int playerThirst = 0;
int playerXp = 0;
int playerXpNextLvl = 50;
int playerLevel = 1;
int playerNextLevel = 2;
int Strenght = 0;
int Sight = 0;
int Speed = 0;
int Intelligence = 0;
int Magic = 0;
int Charisma = 0;
int Luck = 0;
int Defense = 0;
}
So i have all these values, that i obviously have to save in a game file, but i still can’t seem to understand, how it’s all done at all, do i have to write it all (Every single value) into a different script with [serializeable] in it? It’ll break a lot of stuff in my scene, and it would be rather upsetting if i’ll have to rewrite everything from the ground up just to make saving and loading working…
Pardon me for bad english, and thanks for your time.
A little edit: Keep in mind, that i have a lot more code with other values as well, i would need to save them somehow too, but i just can’t seem to understand it at all
In the .sln file you can name the assmeblies. if you inspect the .sln file you will find a line like this Project("{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{1AF10902-9781-58C1-C1BA-8EC10E1CFC9A}" Where is a simple map of name - file. Both can be anything else.
– Martin_Gonzalez