Selecting saved list data into a unity list without overriding current list
Posted: Sat Aug 08, 2020 7:47 am
I have a Master list of all of the Potions in my game, right now its only two but will become 100+ in the future. I have a ItemMaster class and a potionMaster that has a list of ItemMaster. The goal is to save the number of each item and settings the player has, the ItemObject is a SO and does not need to be saved because the Master list should be fixed. I need to set everything in "Item State" and "Amount of Item" to the players saved values.
and
Is it possible to select each sub-key in the saved ES3 file? Below is the 2 potions saved in the ES3 file and the current Save and Load Code. I feel the Load save is wrong but I am just not sure why. I am pretty new to unity so I might just be doing something wrong, so any feedback would be great.
I feel like I should just be able to select the main Key "potionMaster0" and the sub-key "itemState". Is this thinking wrong?
update 8/9: I got it working by off loading the data into a itemTempList all at once, then transfer the data into the master list without overriding the SO. Keeping the SO untouched makes adding items in the future much easier and I don't have to add them to the Easy Save 3 Ref. I still would like to know how you would approach the issue above, is there a better way?
Code: Select all
public class ItemMaster
{
[ES3NonSerializable]
public Item itemObject;
[Header("Item State")]
public ItemState itemState;
public bool itemFavorite;
[Header("Amount of Item")]
public int itemNormalQuality;
public int itemLowQuality;
public int itemHighQuality;
public int itemEnchantedQuailty;
}
Code: Select all
[CreateAssetMenu(fileName = "New Potion Master", menuName = "Add/Master/Potion Master")]
public class PotionMaster : ScriptableObject
{
public bool potionDirty;
public string potionHash;
public List<ItemMaster> potionList = new List<ItemMaster>();
}
I feel like I should just be able to select the main Key "potionMaster0" and the sub-key "itemState". Is this thinking wrong?
update 8/9: I got it working by off loading the data into a itemTempList all at once, then transfer the data into the master list without overriding the SO. Keeping the SO untouched makes adding items in the future much easier and I don't have to add them to the Easy Save 3 Ref. I still would like to know how you would approach the issue above, is there a better way?