Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: shadowof047 on November 02, 2016, 07:52:59 PM

Title: How Should i save ArrayList of Sprites ?
Post by: shadowof047 on November 02, 2016, 07:52:59 PM
Hello .

I'm trying to make a simple inventory system for my game .

Every time the player picks up and item , i clone my "Item" prefab ( from the assets folder),which contains an sprite image component, then change its name and sprite and parent it to my "Inventory" GameObject .

When i want to save , i iterate through all the childs of the "Inventory" GameObject , and save their Names and Sprites to seperate List Arrays , so that when i load , i can create the items which was Parented the "Inventory"

I can save the Names Array List easily with EasySave2 , since it contains only Strings , but ES2 doesnt support Sprites ,how can i save the Sprites Array List ?

Alternatively , Since the name of the items and their respective sprites are the same , how can i search the asset folder for the respective sprite ?
Title: Re: How Should i save ArrayList of Sprites ?
Post by: jeanfabre on November 04, 2016, 05:35:55 AM
Hi,

 no, don't save sprites or assets in general in arrayList for saving and loading as txt, you'll loose referencing.

 instead, use simply string that you can then deduce what sprite or asset it means, by using  naming conventions for example.

Bye,

 Jean
Title: Re: How Should i save ArrayList of Sprites ?
Post by: dudebxl on November 04, 2016, 03:00:00 PM
if you wanna take a risk, you could convert your sprite to a texture then compress the texture (using texture compression action) and now you have a string that you can save but as JeanFabre said not a great idea.