REQUEST EXAMPLES AND TUTORIALS HERE

Examples using Easy Save's API code
Krakentanz
Posts: 5
Joined: Wed Jun 08, 2022 10:49 am

ES3Cloud.php

Post by Krakentanz »

Hi,

since you asked - i have a request for a tutorial :idea: :?: :

Could you elaborate on how to set up the cloud server please?

The Docs just say "put ES3Cloud.php file on your server". Maybe it's just me being too inexperienced, but it would help me a great deal to know more about that server. Questions are:

- where to put the file exactly (like, what directory)?
- What Version of php do i need to install on that server?
- any additional software requirements? What needs to be installed/configured on that server for the .php to do it's job? just php?
- do i need to have any MYSQL databases up and running in the first place, or does ES3Cloud.php do the whole setup job for me?
- what does that file actually do? Is it the server-code itself? Or is it just a setup script? If so, what does it install?

stuff like that would be great to know, as a help for setting this up, and also cause i don't just want to execute some php on my raspberryPI that i don't know what it does...

Thank you so much, and thumbs up for the awesome job that you did with EasySave in general!!
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: REQUEST EXAMPLES AND TUTORIALS HERE

Post by Joel »

Hi there,
where to put the file exactly (like, what directory)?
This can be anywhere which can be accessed by a HTTP request.
What Version of php do i need to install on that server?
We don't use anything out-of-the-ordinary, so any version will be fine.
any additional software requirements? What needs to be installed/configured on that server for the .php to do it's job? just php?
Just PHP, MySQL and the server software itself is all that is required.
do i need to have any MYSQL databases up and running in the first place, or does ES3Cloud.php do the whole setup job for me?
During the setup process you will be asked for the details of a MySQL database where Easy Save can install it's tables. Easy Save will then install the tables on the database for you.
what does that file actually do? Is it the server-code itself? Or is it just a setup script? If so, what does it install?
The ES3Cloud.php script installs the MySQL database, creates a PHP file called ES3Variables.php containing the information such as database details and the API key. Once setup has completed the ES3Cloud.php file then accepts HTTP requests from your Unity client and communicates with the MySQL server to upload or download data to/from the server.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
bradford
Posts: 1
Joined: Sat Jun 11, 2022 4:38 pm

Re: REQUEST EXAMPLES AND TUTORIALS HERE

Post by bradford »

Scenario: I'd like to enumerate existing save data, and also sort existing save data by last-modified time.

Are there any ES3 APIs that let me do that?

If there aren't any APIs, are there any best practice patterns or examples that are recommended?

As one specific example, If I save game data into various keys as shown below, is it possible to enumerate/sort each save game entry?

Code: Select all

ES3.Save("savegame1", data);
ES3.Save("savegame2", data);
ES3.Save("savegame3", data);
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: REQUEST EXAMPLES AND TUTORIALS HERE

Post by Joel »

Hi there,

You can use ES3.GetKeys to get each key in a file, but no time data is associated with this. To sort then you would need to save your own time data as a separate key for each key and use these to sort the data yourself.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Coldwynn
Posts: 22
Joined: Sun Oct 30, 2022 11:56 am

Re: REQUEST EXAMPLES AND TUTORIALS HERE

Post by Coldwynn »

Hi,

I've been teaching myself Unity, C# for about 2 months now, and Easy Save 3 for about 2 weeks, and my frustration threshold has finally been overwhelmed. Would it be too much to ask that a complete, working sample code for saving and loading gameObjects and prefabs be posted here - along with some in depth comments, step by step, along the way?

It took me a day to realize that the sample code in the manual: ES3.Save("myGameObject", go); what "key" meant, and that (heavens!) "go" here was not an EasySave command but meant the gameObject name.

And then it took me another day to realize that I had not both: activated the prefabs and put on the EasySave manager.

Just today, I found nuances where if the prefab does not already exist on scene, then one should be created on saving/loading?

Plus (and I understand that this is more my fuzzy understanding of the camera making the object sometimes not appear at particular zoom levels, but) there's the issue of Instantiated gameObject parent/child if I try to LoadInto an existing .png image / gameObject coupled with the sorting orders >sigh< .... so if you can make my understanding of the basic process clear, I can work on the nuances.

Thank you for your time and consideration.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: REQUEST EXAMPLES AND TUTORIALS HERE

Post by Joel »

Hi there, and thanks for getting in contact :)

As this is the first time this has been requested I've created an example for this here:
https://moodkie.com/forum/viewtopic.php ... 92&p=10526
It took me a day to realize that the sample code in the manual: ES3.Save("myGameObject", go); what "key" meant, and that (heavens!) "go" here was not an EasySave command but meant the gameObject name.
You can find information on what the parameters of methods mean in the API reference:
https://docs.moodkie.com/easy-save-3/es3-api/es3-class/

It also sounds like you may not have found the Getting Started guide as the parameters of the ES3.Save and ES3.Load methods are also explained in there:
http://docs.moodkie.com/easy-save-3/getting-started/
And then it took me another day to realize that I had not both: activated the prefabs and put on the EasySave manager.
Have you taken a look at the Saving and Loading GameObjects guide? These are explained in there:
https://docs.moodkie.com/easy-save-3/es ... s-prefabs/
Just today, I found nuances where if the prefab does not already exist on scene, then one should be created on saving/loading?
A prefab instance is a GameObject which is instantiated at runtime (see Unity's documentation for more info: https://docs.unity3d.com/Manual/Instant ... efabs.html), so a prefab will never already exist in the scene after you leave that scene. In this case Easy Save will automatically create an instance of that prefab.
Plus (and I understand that this is more my fuzzy understanding of the camera making the object sometimes not appear at particular zoom levels, but) there's the issue of Instantiated gameObject parent/child if I try to LoadInto an existing .png image / gameObject coupled with the sorting orders >sigh< .... so if you can make my understanding of the basic process clear, I can work on the nuances.
I'm sorry, I'm afraid I don't understand what you mean by this. Could you clarify?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Coldwynn
Posts: 22
Joined: Sun Oct 30, 2022 11:56 am

Re: REQUEST EXAMPLES AND TUTORIALS HERE

Post by Coldwynn »

Joel,

Thank you so much for the very quick and informative response. I've just spent the better part of the day going through the sample and explanation and am able to write a working script for saving and loading (still working on understanding the difference between Load and LoadInto) gameObjects and prefabs. Again, thank you for your time.
Coldwynn
Posts: 22
Joined: Sun Oct 30, 2022 11:56 am

Re: REQUEST EXAMPLES AND TUTORIALS HERE

Post by Coldwynn »

I'm sorry, I'm afraid I don't understand what you mean by this. Could you clarify?
This has to do with my, as of now, incomplete understanding of ES3.Load and ES3.LoadInto as applied to saved gameObjects or prefabs.

I understand that with the ES3.Load an instance of the object is created, but when I implement it, I don't see the instance (although a Debug.Log of the vector3 values show that it is "there"). Where is the instance in the Hierarchy? Does it instantiate on the original parent? What if I had Destroy(ed) the parent prior to the load, where does it instantiate then (especially if I have multiple gameObjects on scene)?

Likewise with ES3.LoadInto ... Does this mean that the receiving gameObject acquires all the components (replacing its own original settings) of the gameObject being loaded?

I'm working through several script variations to try and tease out the differences.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: REQUEST EXAMPLES AND TUTORIALS HERE

Post by Joel »

Coldwynn wrote: Mon Oct 31, 2022 1:04 am
I'm sorry, I'm afraid I don't understand what you mean by this. Could you clarify?
This has to do with my, as of now, incomplete understanding of ES3.Load and ES3.LoadInto as applied to saved gameObjects or prefabs.

I understand that with the ES3.Load an instance of the object is created, but when I implement it, I don't see the instance (although a Debug.Log of the vector3 values show that it is "there"). Where is the instance in the Hierarchy? Does it instantiate on the original parent? What if I had Destroy(ed) the parent prior to the load, where does it instantiate then (especially if I have multiple gameObjects on scene)?

Likewise with ES3.LoadInto ... Does this mean that the receiving gameObject acquires all the components (replacing its own original settings) of the gameObject being loaded?

I'm working through several script variations to try and tease out the differences.
Hi there,

ES3.Load will create a new instance if one with the same instance ID doesn't already exist. For example, the following code would load the data into the existing instance:

Code: Select all

var go = new GameObject();
ES3.Save("go", go);
var loadedGo = ES3.Load<GameObject>("go");
Debug.Log(go == loadedGo); // This will output 'true'.
If we were then to exit play mode and re-enter, and run the following code, it would create a new instance as GameObject with the same instance ID will no longer exist in the scene (as it will have been destroyed when we exited playmode):

Code: Select all

var loadedGo = ES3.Load<GameObject>("go"); // This will be a new instance.
Note that if we were to do the following instead of the above code, it would still create a new instance because the GameObject we've created ourselves won't have the same instance ID as the one in the file.

Code: Select all

var go = new GameObject();
var loadedGo = ES3.Load<GameObject>("go");
Debug.Log(go == loadedGo); // This will output 'false'.
The only way to create an instance with that instance ID would be to load the GameObject from the file, which will assign that instance ID to it.

Another thing to note is the strange way that Unity destroys objects. When you call Destroy(go), it only marks that GameObject to be destroyed and doesn't actually get destroyed until the end of the frame. This means the following code wouldn't create a new instance, because you're destroying and loading on the same frame:

Code: Select all

var go = new GameObject();
ES3.Save("go", go);
Destroy(go);
var loadedGo = ES3.Load<GameObject>("go");
Debug.Log(go == loadedGo); // This will output 'true' because 'go' isn't destroyed until the end of the frame.
This is controlled at Unity's end rather than ours.

-----
Where is the instance in the Hierarchy? Does it instantiate on the original parent?
A GameObject's position in the hierarchy (or it's parent) is defined by it's Transform's 'parent' variable, which is saved with the GameObject.
What if I had Destroy(ed) the parent prior to the load, where does it instantiate then (especially if I have multiple gameObjects on scene)?
If the parent doesn't exist, it can't parent the GameObject to anything and will be placed at the top of the hierarchy. This behaviour is defined at Unity's end rather than ours.
Likewise with ES3.LoadInto ... Does this mean that the receiving gameObject acquires all the components (replacing its own original settings) of the gameObject being loaded?
If the Components are supported types then yes (see the Saving and Loading GameObjects guide for more information on which Components will be saved).

Specifically it does the following when loading a Component:
  1. Check if the GameObject we're loading into already has the Component we're loading.
  2. If it already has the Component, check if we've loaded any data into this Component yet.
  3. If it has the Component and it's not yet been loaded into, load the data into this Component.
  4. Otherwise, add a new Component to the GameObject and load the data into this.
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Coldwynn
Posts: 22
Joined: Sun Oct 30, 2022 11:56 am

Re: REQUEST EXAMPLES AND TUTORIALS HERE

Post by Coldwynn »

Thank you for the clarifications. This was very helpful indeed.

... Now I have to teach myself how to use Easy Save 3 to save arrays (I'm trying to develop an American Football type game and so I have to save and load a minimum of 23 playing characters, each with 8 stats; the team playbook with as many as 60 plays - per however number of teams) ... I'll be back here to ask for more tutorials I'm sure.
Post Reply