c# - How to save dictionary data or array list data to playerprefs more effeciently? -


does know how save dictionary data or array list data playerprefs more efficiently?

for example have class item:

using unityengine; using system.collections; using system.collections.generic;  // make class item public class item {     public string itemname;     public int itemid;     public string itemdesc;     public string itemicon;     public gameobject itemmodel;     public int itemtime;     public int hightprice;     public int stdprice;     public int itemstock;     public int harvest;     public rawtree rawtree;     public itemtype itemtype;     public itemprod itemprod;     public itemlocation itemlocation;     public itemmerchant itemmerchant;     public int lvlunlock;     private string basename;     public int spawnrate;     public int minqtyspawnbuy;     public int maxqtyspawnbuy;     public int minqtyspawnsell;     public int maxqtyspawnsell;     public int itemexp;       public enum itemtype {         raw,         admirable,         valuable     }      public enum rawtree {         bigtree,         smalltree,         field,         none     }      public enum itemprod {         corps,         dairy,         juicejammaker,         kitchen,         bakery,         crafthouse,         chickencoop,         fishingspotmountain,         cowpasture,         lunamine,         pigpen,         fishingspotlake,         tropicalwood,         sheeppasture,         fishingspotsea,         beebox,         homeindustry,         merchant     }      public enum itemlocation {          home,         orchard,         forest     }      public enum itemmerchant {          margaret,         lucy,         bobby,         roger,         grace     }      public item (string name, int id, string desc, int harvestx, int time, int stdpricex, int hightpricex, int stock, int lvlunlockx, rawtree rawtree, itemtype type, itemprod prod, string folderx, itemlocation location, itemmerchant merchant, int rate, int minspawnbuy, int maxspawnbuy, int minspawnsell, int maxspawnsell, int exp) {         itemname = name;         itemid = id;         itemdesc = desc;         harvest = harvestx;         itemtime = time;         stdprice = stdpricex;         hightprice = hightpricex;         itemstock = stock;         lvlunlock = lvlunlockx;         rawtree = rawtree;         itemtype = type;         itemprod = prod;         itemicon = folderx;         itemlocation = location;         itemmerchant = merchant;         spawnrate = rate;         minqtyspawnbuy = minspawnbuy;         maxqtyspawnbuy = maxspawnbuy;         minqtyspawnsell = minspawnsell;         maxqtyspawnsell = maxspawnsell;         itemexp = exp;     }      public item() {      } } 

then create list item :

public list<item> items = new list<item> (); 

first: how save items playerprefs more effecient ?

for example have data on dictionary:

public dictionary <string, dictionary <string, int> > productsellmargaret; 

second: how save productsellmargaret playerprefs more efficiently?

how save both of them playerprefs can continue call data when exit game , play again continue data?

a precise answer be

"don't save larger data playerprefs"

playerprefs used save small values game settings etc. saving kind of configurations in playerprefs way it.

but

when comes saving large scale data lists of objects or nested dictionaries. advised store file.

how should parse data objects , save file?

  1. there different ways of doing this. 1 of them serializing data objects using binaryformatter , saving in file using system.io. quick tutorial achieve refer to: tutsplus: how save , load players' progress in unity

  2. again, 1 way of doing it. can use other methods well. unity's new json serializer option you.

  3. if want work xml instead of json, xml serializer choice go with.

hope helps.


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -