- Home /
Saving My Inventory
Hi guys, I'm neither completely newbie, nor professional.
Here I got a class:
public class Item{
public Texture2D texture;
public string name;
public GameObject[] gameObjects;
public Transform prefab;
public float req_gold;
public bool owned;
public bool merchant;
public string slot;
public string type;
}
and I use
public Item[] items;
public Item[] bag_items;
this lines to create my inventory and my bag. (Player can only use items which are in bag)
so then, Can you tell me how can I store my inventory data? (I could save them between scenes, I add don't destroy on load to object, But when I open inventory I can't change item's place )
If you'll suggest "serializing", please explain it how I do it?
Answer by lancer · Aug 12, 2013 at 09:44 PM
http://whydoit.com/ has an amazing, easy to use Serializer. I'm starting to use it a lot.
It's because his name (and domain name) is http://whydoidoit.com
@Narv: please don't start a downvote-fight with lancer.
Answer by cdrandin · Aug 10, 2013 at 11:44 PM
check out http://answers.unity3d.com/questions/182491/remembering-variables-between-scenes.html
Couple of ways of achieving this.
Thank you, but as I told, I have problem with "don't destroy on load". And I want to "store" it. When I close the game and open it again, my inventory wouldn't be changed.
$$anonymous$$ight prove helpful. X$$anonymous$$L serialization. Store data onto a file, then when the file exist you ins$$anonymous$$d read from that. http://wiki.unity3d.com/index.php?title=Saving_and_Loading_Data:_XmlSerializer
What is Serialization?
Thank you. I'll save gameobjects name on xml and load them with name.
Answer by TimBorquez · Aug 13, 2013 at 12:33 AM
i use static variables to use them in between scenes and playerprefs to save them
Answer by sholom1 · Mar 24, 2017 at 07:51 PM
i have a one scene game besides the menu. why not have a list and save the scene? will that not save the list?