General ES2 Workflow + Questions

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
justinl
Posts: 7
Joined: Mon May 27, 2013 3:46 am

General ES2 Workflow + Questions

Post by justinl »

Hello!

Before I start using your package I just wanted to clear up a few questions on the workflow. I have a scene with a mix of spawned and Instantiated objects as well as objects directly placed into the scene.

Should I create a save game manger that each object subscribes to and then when I save the game, have the save game manager iterate through this list to save everything directly? OR can I have each objects own script save itself instead of having the manager do it?

Also, it would appear that each object requires a tag to save/load. This is correct? For example, if I have 100 enemies spawned at the start of the game across a large terrain, would it be appropriate to use their InstanceID as their tag when saving? When I quit the application and restart the game, all InstanceID's will be changed. How will each enemy be able to know which position/rotation to resume to? Or does each instance of a prefab need to have a unique identifier that's "baked" into that prefab instance before the game is run?

Another question: when I use ES2.Save(), to confirm, I need to specify the path and tag parameter each time? Like this: ES2.Save(transform.position, "myFile.txt?tag=myPosition");

It seems a bit redundant to have to type that each time, no? Is there a way built into ES2 to have the path saved in the settings so that I could just do ES2.Save(transform.position, "myPosition"); Is there any particular reason I'd want to save to different files each time? Or having everything in 1 save file makes the most sense? Is there an easy way to extend ES2 without your source code?

A small scene file included with the package download that shows a really basic setup I think would do wonders to illustrate how all the pieces work together to save and load a game. Something as simple as a few objects in a scene and you can move them around, then save their new positions, and then reload the game and load the previously saved positions.

Thanks!
Justin
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: General ES2 Workflow + Questions

Post by Joel »

Hi Justin,

It is acceptable to either create a save game manager or to save things directly. However, you shouldn't use the instanceID as this changes every time the application loads. Instead, you should keep all of your instantiated objects in an array or list and use the position in the array as the tag, and also save the length of the array so you know how many objects you've saved. There's a basic example of this HERE.

Regarding the path, most people have a static variable which stores the filename, and everything else apart from the tag, and then they append this to the path. For example:
public static string saveFile = "myFile.txt?encryptionpassword=myPassword&tag=";
And then when you save/load, you can do:
ES2.Save(myData, saveFile+"myTag");
It needs to be supplied with a full path, otherwise it doesn't have enough information to know what the path is: whether it's a file, folder, tag, URL, etcetera. If you did ES2.Save(myData, "aString"), it would actually create a new file called "aString" and save the data into that, using a default tag.

Some people prefer to have some data in one file, and other data in another. It's also acceptable to have a separate file for each piece of data you're saving, and avoid using tags altogether. It's just a matter of preference, as there's really no noticeable difference in performance.

With regards to the source code, we've made the source code available before, but people very much abused it and we found our code in a number of other plugins. However if there was demand for it, we could consider splitting it into multiple DLLs, which would then make it extendable. However, there doesn't seem to be much demand for this at the moment.

We've added example scenes to our To Do list, and I'll hopefully get them included in Easy Save by the end of next week. We're also going to add a beginners tutorial to the Examples page.

Thanks for your suggestions, it is very much appreciated!

Joel
justinl
Posts: 7
Joined: Mon May 27, 2013 3:46 am

Re: General ES2 Workflow + Questions

Post by justinl »

Thanks for your thorough answer Joel!

A follow up question I have: You mentioned that you recommend using the position in the array as the tag. Does this mean that every time I launch the game, that objects are instantiated in the exact same order? For example, I have a spawner GameObject that I place into the world and on Start() it will either spawn or not spawn an enemy (50% chance an enemy will spawn). Once that enemy is spawned, I would then add the enemy to my "prefabs to save" array. However, I can already see that this method probably doesn't work then and the better bet, would be to not do the 50% chance spawn, but instead, spawn everything and then do a 50% chance that the enemy will be disabled. Does that sound right?

Also, would it be correct to assume that every time I launch my game, the game should launch with exactly the same Objects every time (no random chance spawning on items I want to save), and then the data I'm loading from ES2 is basically Transform and state related data?

Lastly, since I'm just placing all my enemies into the scene, it seems that there would be no way to predict the order at which they were added to an array (I presume that Unity may not call their Start() methods in the exact same order every time. Or do they?). If they don't, I suppose that would mean that each enemy would then have to save to it's own file based on a unique ID I give each enemy that stays consistent (not InstanceID). Does that sound correct?

Thanks!
Justin
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: General ES2 Workflow + Questions

Post by Joel »

Hi Justin,

Because your questions more closely relate to game implementation rather than Easy Save itself, I'm afraid I can't give you any advice.

I can say this however: The order of the objects in the array isn't important. What is important is that we know how many objects we want to save. If we know how many objects we need to save, we can give them each a number, where the first object has tag number 1, and the last object has tag number *however many objects we have*. It doesn't matter if it changes order, because every object is going to be saved at the same time.

If however you wanted each object to save their own state, and save at different times to each other, you would have to manually give each object their own unique tag. How you do this would be up to you, but InstanceID is very much unsuitable for this. There is currently a request for Unity to have persistent InstanceIDs, but I forget where the petition page is.

Aside from the example I linked you to, I'm afraid I can give you no more assistance than this.

All the best,
Joel
justinl
Posts: 7
Joined: Mon May 27, 2013 3:46 am

Re: General ES2 Workflow + Questions

Post by justinl »

Thanks Joel,

Surely the question was about the implementation of Easy Save though. No? Either way, it does sound like I'll need to implement some sort of persistent ID system. Sounds good!

I worked with the Unity Serializer before and when you load the data with it, it seems to wipe out your saved objects from the scene and then re-Instantiates game objects that were saved. Your system does not do that, correct? It simply stores whatever information I want, and then if I quit the application and then run the game again, my scene will just load as it always normally does, and at that point in time, I should fetch whatever data I've saved using ES2 and apply it to my game objects. Correct?

Thanks!
Justin
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: General ES2 Workflow + Questions

Post by Joel »

Hi Justin,

Our rule-of-thumb is that if it requires us to know the inner workings of your project, we can't talk about it. We've had legal trouble with this recently, which is why we're very cautious with this for the time being. With regards to your previous post, it might be easiest to go the '50% chance of being disabled' route.

You are correct Justin. As far as I'm aware, Unity Serializer uses reflection libraries, which are unreliable and/or unsupported on most platforms. It's also very inefficient and uses a large amount of processing power and memory. Easy Save on the other hand is very efficient, and allows you to save only the data which needs saving.

We are actually working on a method which gives the best of both worlds at the moment, but I'm unable to give a timeframe for this. It's all very exciting though :)

Joel
justinl
Posts: 7
Joined: Mon May 27, 2013 3:46 am

Re: General ES2 Workflow + Questions

Post by justinl »

Thanks Joel!

I respect your cautiousness regarding legal matters and I appreciate you throwing out a basic recommendation regarding my previous "50% chance disable" question. I'm excited to start using your product now that I have my head around how I want to implement it. I like how manual and simple it is compared to Unity Serializer. I loved Unity Serializer but it felt like a lot was going on behind the scenes and for the purpose I needed it, the performance was really suffering and I hope your solution will be more simple and thus, have better performance.

One thing that Unity Serializer comes with is a simple UniqueIdentifier script that generates a unique ID for each object when you create it, and this ID is persistent whether you restart the game. It also re-generates itself if you duplicate an object. Quite handy!

Being a customer will I automatically receive notification about your updates or do I need to register somewhere?

Cheers!
Justin
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: General ES2 Workflow + Questions

Post by Joel »

Hopefully we'll be able to be less cautious in the near future :) And thank-you for the praise, it's very much appreciated.

We'll look into adding our own unique identifier functionality as you've described, though I can think of an even easier way to implement it, but that's a closely guarded secret for the time being!

For notification about our updates, you can subscribe to the 'News & Updates' forum.

All the best,
Joel
Locked