Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Save Game Pro - Gold Update

Discussion in 'Assets and Asset Store' started by hasanbayat, Nov 3, 2017.

  1. Pascal-

    Pascal-

    Joined:
    Mar 23, 2013
    Posts:
    29
    Thank you a lot!
     
  2. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    413
    Hello. Your asset looks interesting.

    Save Game Pro is capable to save a link between objects?
    For example there is a rocket launcher which launched a guidable rocket into specific target (Transform).

    So there is a script "Rocket" which is attached to rocket GameObject and there is a variable inside this script, for example:

    public Transform target;

    And some another game object placed in this "target" variable.
    So can your tool save and load this link properly?

    How exactly it happens? I mean, how exactly you know which exactly target is set for rocket? As far as I know, "InstanceID" variable of GameObject is readonly, so after the load, target will have another InstanceID. Are you implementing your own "ID manager" for that?

    I am asking this because I tried to use various save load tools from Asset Store and I am extremely surprised that absolutely no one explain this the most fundamental and important aspect of save loading (links between objects). Everyone just provides a tool to "save variable to file" and ignores a necessity to save a links between objects.

    Is there an example scene which explains save load of such links or a tutorial about this aspect?
     
  3. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi, thanks for your interest.

    We can't do saving and loading the references or links between the objects, because they are implemented internally by Unity, and we don't have access to those internal implementation, so such thing cannot be done with our asset, so sorry about this.

    We are looking for forward to adding this feature ,because it is fundamentally important for both us and you.

    But you can achieve this goal by using instantiating objects instead of storing links, for example you can store the information of the target and instantiate them at playtime and reference to the instantiated object.

    Also, the instantiated objects are not stored in the scene, so you should store them and re-instantiate them for using.

    Any further questions are welcome.

    Thanks.
     
    Romenics and Artaani like this.
  4. Pascal-

    Pascal-

    Joined:
    Mar 23, 2013
    Posts:
    29
    Dear @hasanbayat,

    I created a "read.php" file and I add it to the "php-savegamepro-mysql' directory on my server to try to display the saved data on Web.

    Code (CSharp):
    1. <?php
    2.  
    3. include "includes/pollyfills.inc.php";
    4. include "config.php";
    5.  
    6. $action = $_POST['action'];
    7. $secret_key = $_POST['secret-key'];
    8. $username = $_POST['username'];
    9. $password = $_POST['password'];
    10. $data_key = isset($_POST['data-key']) ? $_POST['data-key'] : false;
    11. $data_value = isset($_POST['data-value']) ? $_POST['data-value'] : false;
    12. $type = isset($_POST['type']) ? $_POST['type'] : 'user';
    13. $create_account = isset($_POST['create-account']) ? true : false;
    14. $filename = isset($_POST['file-name']) ? $_POST['file-name'] : $data_key;
    15.  
    16. if ($secret_key !== SECRET_KEY) {
    17.   http_response_code(400);
    18.   exit("The Secret Key is invalid.");
    19. }
    20.  
    21. $get_user_sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
    22. $result = $mysqli->query($get_user_sql);
    23.  
    24. $load_sql = "SELECT * FROM saves  WHERE user_id='" . $user['ID'] . "' AND data_key='$data_key'";
    25. $result = $mysqli->query($load_sql);
    26.  
    27. $data = $result->fetch_assoc();
    28. echo $data['data_value'];
    When I open the "read.php" I get "The Secret Key is invalid.". I guess I'm doing something wrong or I'm missing some steps to display the saved data.

    http://silondi.net/php-savegamepro-mysql/read.php

    Can you please help me?
    Thanks a lot!
     
  5. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    If you want to display the data, you won't need the secret key, remove the lines related to Secret key and you are done:
    Code (CSharp):
    1. <?php
    2. include "includes/pollyfills.inc.php";
    3. include "config.php";
    4. $action = $_POST['action'];
    5. $username = $_POST['username'];
    6. $password = $_POST['password'];
    7. $data_key = isset($_POST['data-key']) ? $_POST['data-key'] : false;
    8. $data_value = isset($_POST['data-value']) ? $_POST['data-value'] : false;
    9. $type = isset($_POST['type']) ? $_POST['type'] : 'user';
    10. $create_account = isset($_POST['create-account']) ? true : false;
    11. $filename = isset($_POST['file-name']) ? $_POST['file-name'] : $data_key;
    12. $get_user_sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
    13. $result = $mysqli->query($get_user_sql);
    14. $load_sql = "SELECT * FROM saves  WHERE user_id='" . $user['ID'] . "' AND data_key='$data_key'";
    15. $result = $mysqli->query($load_sql);
    16. $data = $result->fetch_assoc();
    17. echo $data['data_value'];
    Thanks.
     
  6. Pascal-

    Pascal-

    Joined:
    Mar 23, 2013
    Posts:
    29
    Thanks again for your fast answer!

    I get an error "Fatal error: Call to a member function query() on null in /www/doc/www.silondi.net/www/php-savegamepro-mysql/read.php on line 13"
    Is there something I'm doing wrong or missing?

    Thank you!
     
  7. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    It seems you didn't made the connection by MySQL, try to make the connection using:
    Code (CSharp):
    1. $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    2. if ($mysqli->connect_errno) {
    3.   http_response_code(500);
    4.   echo "Error: Failed to make a MySQL connection, here is why: \n";
    5.   echo "Errno: " . $mysqli->connect_errno . "\n";
    6.   echo "Error: " . $mysqli->connect_error . "\n";
    7.   exit("The MySQL connection failed.");
    8. }
    And then use the query method:
    Code (CSharp):
    1. $get_user_sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
    2. $result = $mysqli->query($get_user_sql);
    3. if (!$result) {
    4.   http_response_code(500);
    5.   echo "Error: Failed to Execute Query, here is why: \n";
    6.   echo "Query: " . $get_user_sql . "\n";
    7.   echo "Errno: " . $mysqli->errno . "\n";
    8.   echo "Error: " . $mysqli->error . "\n";
    9.   exit;
    10. }
    Thanks.
     
  8. Pascal-

    Pascal-

    Joined:
    Mar 23, 2013
    Posts:
    29
    I have now no error but a blank page.

    Code (CSharp):
    1.     <?php
    2.     include "includes/pollyfills.inc.php";
    3.     include "config.php";
    4.     $action = $_POST['action'];
    5.     $username = $_POST['username'];
    6.     $password = $_POST['password'];
    7.     $data_key = isset($_POST['data-key']) ? $_POST['data-key'] : false;
    8.     $data_value = isset($_POST['data-value']) ? $_POST['data-value'] : false;
    9.     $type = isset($_POST['type']) ? $_POST['type'] : 'user';
    10.     $create_account = isset($_POST['create-account']) ? true : false;
    11.     $filename = isset($_POST['file-name']) ? $_POST['file-name'] : $data_key;
    12.  
    13.       $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    14.     if ($mysqli->connect_errno) {
    15.       http_response_code(500);
    16.       echo "Error: Failed to make a MySQL connection, here is why: \n";
    17.       echo "Errno: " . $mysqli->connect_errno . "\n";
    18.       echo "Error: " . $mysqli->connect_error . "\n";
    19.       exit("The MySQL connection failed.");
    20.     }
    21.  
    22.     $get_user_sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
    23.     $result = $mysqli->query($get_user_sql);
    24.     if (!$result) {
    25.       http_response_code(500);
    26.       echo "Error: Failed to Execute Query, here is why: \n";
    27.       echo "Query: " . $get_user_sql . "\n";
    28.       echo "Errno: " . $mysqli->errno . "\n";
    29.       echo "Error: " . $mysqli->error . "\n";
    30.       exit;
    31.     }
    32.     $load_sql = "SELECT * FROM saves  WHERE user_id='" . $user['ID'] . "' AND data_key='$data_key'";
    33.     $result = $mysqli->query($load_sql);
    34.  
    35.     $data = $result->fetch_assoc();
    36.     echo $data['data_value'];
    Should I do something else?
    Thank You!
     
  9. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    This is because of data-key, it is empty, so no data will be retrieved, you need to specify the data key plus specifying other fields too, such as username, password, data-key and action to make it work.

    The data-key is the identifier and the username and password are the user credentials and the action is the operation to do.

    For example you can hard-code this values in the script and give it a try to make sure it works correctly or not.

    Thanks.
     
  10. Pascal-

    Pascal-

    Joined:
    Mar 23, 2013
    Posts:
    29
    Dear @hasanbayat,
    I'm so sorry to bother you but I'm new with that process and I don't get it.

    I tried that but no success. It's still blank.

    Code (CSharp):
    1.     <?php
    2.     include "includes/pollyfills.inc.php";
    3.     include "config.php";  
    4.  
    5.     $action = $_POST['action'];
    6.  
    7.     $username = $_POST['pascal'];
    8.     $password = $_POST['silondi'];
    9.     $data_key = isset($_POST['2']) ? $_POST['2'] : false;
    10.  
    11.     $data_value = isset($_POST['data-value']) ? $_POST['data-value'] : false;
    12.     $type = isset($_POST['type']) ? $_POST['type'] : 'user';
    13.     $create_account = isset($_POST['create-account']) ? true : false;
    14.     $filename = isset($_POST['file-name']) ? $_POST['file-name'] : $data_key;
    15.  
    16.       $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    17.     if ($mysqli->connect_errno) {
    18.       http_response_code(500);
    19.       echo "Error: Failed to make a MySQL connection, here is why: \n";
    20.       echo "Errno: " . $mysqli->connect_errno . "\n";
    21.       echo "Error: " . $mysqli->connect_error . "\n";
    22.       exit("The MySQL connection failed.");
    23.     }
    24.     $get_user_sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
    25.     $result = $mysqli->query($get_user_sql);
    26.     if (!$result) {
    27.       http_response_code(500);
    28.       echo "Error: Failed to Execute Query, here is why: \n";
    29.       echo "Query: " . $get_user_sql . "\n";
    30.       echo "Errno: " . $mysqli->errno . "\n";
    31.       echo "Error: " . $mysqli->error . "\n";
    32.       exit;
    33.     }
    34.     $load_sql = "SELECT * FROM saves  WHERE user_id='" . $user['ID'] . "' AND data_key='$data_key'";
    35.     $result = $mysqli->query($load_sql);
    36.     $data = $result->fetch_assoc();
    37.     echo $data['data_value'];
    here are screen shots of what i have on server:




    I guess I'm missing something like setting the action?
    Thanks for your help!
     
  11. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    No problem, I am here to help, let us chat somewhere easier, like Slack or Discord.
    Do you have any knowledge about PHP?
    The hard-coding of the values meant to set the value of the variables to the string value, not using the $_POST variable, it is a Global variable that stores the data sent from the HTTP POST request, so for now, your code should look like this:
    Code (CSharp):
    1. <?php
    2. include "includes/pollyfills.inc.php";
    3. include "config.php";
    4.  
    5. // We don't need it anymore, because you only need to load data, not taking another action
    6. //$action = 'load';
    7.  
    8. $username = 'pascal';
    9. $password = 'silondi';
    10. $data_key = 'helloWorld';
    11.  
    12. // We want to fetch the data-value, and we don't want to save any value, so we don't need it anymore
    13. //$data_value = isset($_POST['data-value']) ? $_POST['data-value'] : false;
    14.  
    15. // It is the type of user, an optional field, not required, so don't need it
    16. //$type = isset($_POST['type']) ? $_POST['type'] : 'user';
    17.  
    18. // We don't want to create an account for user, we want to fetch the data, no need for this
    19. //$create_account = isset($_POST['create-account']) ? true : false;
    20.  
    21. // It is used for uploading file, so we don't need it in this case
    22. //$filename = isset($_POST['file-name']) ? $_POST['file-name'] : $data_key;
    23.  
    24. // Connecting to MySQL database
    25. $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    26. if ($mysqli->connect_errno) {
    27.     http_response_code(500);
    28.     echo "Error: Failed to make a MySQL connection, here is why: \n";
    29.     echo "Errno: " . $mysqli->connect_errno . "\n";
    30.     echo "Error: " . $mysqli->connect_error . "\n";
    31.     exit("The MySQL connection failed.");
    32. }
    33.  
    34. // Getting user information such as User Unique ID
    35. $get_user_sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
    36. $result = $mysqli->query($get_user_sql);
    37. if (!$result) {
    38.     http_response_code(500);
    39.     echo "Error: Failed to Execute Query, here is why: \n";
    40.     echo "Query: " . $get_user_sql . "\n";
    41.     echo "Errno: " . $mysqli->errno . "\n";
    42.     echo "Error: " . $mysqli->error . "\n";
    43.     exit;
    44. }
    45.  
    46. // Now fetch the user information
    47. $user = $result->fetch_assoc();
    48.  
    49. // Now load the data using the User Unique ID and the data key
    50. $load_sql = "SELECT * FROM saves  WHERE user_id='" . $user['ID'] . "' AND data_key='$data_key'";
    51. $result = $mysqli->query($load_sql);
    52.  
    53. // Fetching the data and output
    54. $data = $result->fetch_assoc();
    55. echo $data['data_value'];
    Added code comments to help you understand what is going on.
    Enjoy!
    Let me know if you had any problem or question.
    Thanks.
     
    Last edited: Dec 18, 2017
  12. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,003
    Hi, I'm interested in purchasing your interesting looking asset but have a question if that is ok?
    I'll need to be able to serialise/save multiple gameobjects (+-200) from a scene, each gameobject has a mesh,mesh renderer,material,and a script, I am almost sure your asset will be able to save these but could you confirm?
     
  13. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi.

    Yes it can, But if your attached custom script is complex, you need to provide a custom type for it, then you will be able to save it.
    But, If it is a mobile game, I don't recommend you to do such thing, try to store needed data, not whole objects.
    And if it is a standalone game, there is no worry, go ahead.

    Let me know if you had any problems, Contact Us
    Thanks.
     
    khos likes this.
  14. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Save Game Pro updated to version 2.3.3, here are the changes:
    • Add Save Globals Playmaker Action
    • Add Load Globals Playmaker Action
    • Install & Uninstall Integration now enabled or disabled by their installation state
    Now you can save & load PlayMaker global variables by single shot.
     
  15. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    106
    Hello. I'm thinking about acquiring your asset. But I can't see if you have any File Viewer to view saved data. Do you have such a feature? Also, do use binary data format or something else? May I encrypt saved data?
     
  16. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi, No, Save Game Pro doesn't have the such feature to view the file content, but I can include it, if you really need it.
    Save Game Pro supports both Binary and JSON format for serialization that means, we are using Binary as encrypted data and JSON for user-friendly data. And there is no need to use encryption for Binary one.

    Thanks.
     
  17. Straafe

    Straafe

    Joined:
    Oct 15, 2012
    Posts:
    63
    I'm on the fence for this asset, as it seems to be the newest (and potentially best) asset in the save game field. I already own allSave Pro, as it looked too good to be true seeing that it is automated, but it produced all sorts of problems to the point where I didn't feel safe using it in my project.

    All I have are some custom scripts and classes on my objects, and the user can spawn and import additional objects, and I'd like all the objects saved including their transforms and all the values and variables in my custom scripts. Is this easy to do? I checked your basic guide and it shows how to save an int and a transform, but is it easy to just save all components of all objects active in my scene to a file? The scene is fairly simply with probably always less than 30 objects, sometimes less than 10.
     
  18. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi.

    Yes, you can save whole game object (there is an example for it included), but if you want to save custom scripts, you will need to provide some custom type for them to allow Save Game Pro save them, maybe you don't need to provide custom type for all of them, just for complex ones.

    Save Game Pro provides the API for the developer to handle the all sort of saving and loading by itself.

    Thanks.
     
  19. Straafe

    Straafe

    Joined:
    Oct 15, 2012
    Posts:
    63
    Very cool. Does each object save to its own file? Say I have the 10 different objects, can I save them all to a single file?
     
  20. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Yes you can, create a list or array of the objects and save them to the file.
    Like this:
    Code (CSharp):
    1. List<GameObject> objects = new List<GameObject> ();
    2. objects.Add ( myGameObject );
    3. SaveGame.Save ( "objects.dat", objects );
    4.  
    5. // Then load them back
    6. SaveGame.LoadInto ( "objects.dat", objects );
    Thanks.
     
  21. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    252
    Last edited: Feb 15, 2018
  22. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Yes, I had same problem here, I am trying to contact our Webmaster to ask what causing this issue and fix it as soon as possible.

    Thanks for reporting us, we will fix it as soon as possible, So accept our apologies for inconveniences.
     
  23. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    252
    OK, having read through the documentation, I have a couple of questions:

    1) How do the identifier strings get serialized into to binary format? If I use long IDs for clarity, will my saved games become significantly bigger?

    2) Can I detect whether a saved game is in binary or JSON format? I'd like to use JSON for saving from the editor but binary for saving from a build (to make development easier while keeping file sizes small for actual players), and I'd like both to be loadable everywhere.
     
  24. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Let me answer each question individually:
    1. The identifier is the name of the file, or more accurately the path of the file, that you can include any valid file name, and it is not serialized in the file itself.
    2. No, currently there is no way to detect this, as the settings is not serialized in the file itself, so for this, you need to manually specify the serializer in build or in editor by just using the Default Settings of the Save Game API, and the true way is to specify the serializer manually.
    Thanks.
     
  25. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    252
    [Final edit: I bought the package and figured out how to use it for me needs. So no need to respond but I'm leaving it here in case the questions are of interest to others.]

    1) OK, I'm a bit confused about this. There's examples like this in the documentation:

    Code (csharp):
    1.  
    2. SaveGame.Save<int> ( "score", score );
    3.  
    So is this saving one integer value to a file named "score", without any extension?

    There are also examples like this:

    Code (csharp):
    1.  
    2. writer.WriteProperty ( "x", vector3.x );
    3.  
    Here I'm quite certain "x" is not a file name but simply an identifier. So my question stands: Are they serialized simply as strings or in some other, more efficient way?

    And if I want to save a lot of things into one file, is the correct way to call

    Code (csharp):
    1.  
    2. SaveGame.Save<SaveGameRootClass>("save_name.sav", saveGameRootObject)?
    3.  
    and define custom SaveGameType_ classes for every class I want to save?

    2) Does it at least throw a nice exception so I can first try to read the file as binary and if that fails use JSON? (Edit: Forget about this one. I realized I can just use different file name extensions for JSON and binary and load them accordingly.)

    Edit:

    3) Does the custom save class have to be named SaveGameType_[my class name]? Or is that just an example? It seems to me the interface and the AssociatedType method would be enough to detect the connection.
     
    Last edited: Feb 17, 2018
  26. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    252
    One more comment (and sorry for double-posting):

    It would be great if the SaveGameType scripts could apply to all subtypes of an interface or an abstract class. (I tried to change SaveGameTypeManager.cs to do this, but it got automatically overridden.)

    Not a big deal to create boilerplate classes for all my actual saver classes, but a bit inconvenient.

    Edit: Another question:

    The JSON generated seems to be - at least when viewed in Notepad, WordPad, or Open Office - in a format with no white space, making it difficult to read. Is there some setting I'm missing?
     
    Last edited: Feb 18, 2018
  27. Davide1104

    Davide1104

    Joined:
    Jun 12, 2013
    Posts:
    33
    Hi, after installation
    i need to connect unity to a php/MySQL SERVER
    i made the installation but then it gave me this error
    Bad Request, the Request should use HTTP POST method with an "action" parameter.

    this appear when I try to open by the browser web the url php

    the database has ben created and filled but there is no guide to continue understand how to use save game pro with a server php MySql

    unity save correctly but when i try to load data, console give me 3 errors

    Load Failed
    UnityEngine.Debug:LogError(Object)
    BayatGames.SaveGamePro.Examples.<DoLoad>c__Iterator1:MoveNext() (at Assets/BayatGames/SaveGamePro/Examples/Cloud Saving/Scripts/WebCloudSave.cs:121)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)


    Generic/unknown HTTP error
    UnityEngine.Debug:LogError(Object)
    BayatGames.SaveGamePro.Examples.<DoLoad>c__Iterator1:MoveNext() (at Assets/BayatGames/SaveGamePro/Examples/Cloud Saving/Scripts/WebCloudSave.cs:122)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

    Error: The Data with given identifier does not found.
    UnityEngine.Debug:LogError(Object)
    BayatGames.SaveGamePro.Examples.<DoLoad>c__Iterator1:MoveNext() (at Assets/BayatGames/SaveGamePro/Examples/Cloud Saving/Scripts/WebCloudSave.cs:123)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
     
    Last edited: Feb 23, 2018
  28. Davide1104

    Davide1104

    Joined:
    Jun 12, 2013
    Posts:
    33
    Maybe this could be usefull for someone else
    I try to understand php/MySQL function load, is not much clear.
    there are not many indications about it
     

    Attached Files:

  29. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    90
    Hello,

    can i also read/save global data, not user related?
    It' looks like that the user has to register a username and password.
    I can see no example for user registration in your documentation
    Will it be checked if username is already taken?

    It seems that the data is saved encrypted in mysql-databse, for my needs i need the data decrypted, is this possible?

    Can is host the php-files on a https server?

    I'd like to take googleplay username as username

    knuppel
     
    Last edited: Feb 25, 2018
  30. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    252
    I'm pretty sure I've found a bug:

    If I have an empty block, it won't put a comma between that empty block and the next property. Like this:

    Code (csharp):
    1. "some_block": {}"another_property":"property_value",
    This is probably because it sets the "m_isFirstProperty" variable to true when it starts the empty block but doesn't set it back to false because it never encounters that first property.

    Now you might want to ask what the purpose of an empty block is. In my case it's there because there's something I generally want to save, but it has many subclasses, and not all of them have anything to save.

    I'm going to circumvent this by adding a dummy field to those subclasses but I just wanted to let you know.

    Also: Could we have an option to prettify the resulting JSON? Especially as the file can't be opened and formatted by regular JSON viewers, because apparently the "Infinity" and "-Infinity" values are not supported by them.
     
    Last edited: Feb 26, 2018
  31. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Oh, sorry for my late, I didn't get any notification from this forum about this message, so excuse me, if you want a fast response, just use my email hasanbayat1393@gmail.com
    I think you might be right, I need to test it out too.
    There is no option for prettifying the JSON currently, but I planned to include it, for now you can use other libraries to prettify the JSON just google C# or Unity json prettify and you will find good resources.

    Thanks.
     
  32. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    I have tested same now, but it works pretty well, here is the JSON output:
    Code (CSharp):
    1. {"subData1":{},"subData2":{}}
    And my code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. using BayatGames.SaveGamePro;
    6.  
    7. public class Test : MonoBehaviour
    8. {
    9.  
    10.     public class Data
    11.     {
    12.  
    13.         public SubData subData1 = new SubData();
    14.         public SubData subData2 = new SubData();
    15.  
    16.     }
    17.  
    18.     public class SubData
    19.     {
    20.     }
    21.  
    22.     // Use this for initialization
    23.     void Start()
    24.     {
    25.         SaveGameSettings settings = SaveGame.DefaultSettings;
    26.         settings.Formatter = new BayatGames.SaveGamePro.Serialization.Formatters.Json.JsonFormatter();
    27.         SaveGame.DefaultSettings = settings;
    28.         Save();
    29.     }
    30.  
    31.     public void Save()
    32.     {
    33.         Data data = new Data();
    34.         SaveGame.Save("data.txt", data);
    35.     }
    36.  
    37.     public void Load()
    38.     {
    39.         SaveGame.Load<Data>("data.txt");
    40.     }
    41.  
    42. }
    43.  
    It might be an issue with your data, we need to debug on your side.

    Thanks.
     
  33. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi there, I think you already asked it on Discord, or may I late here, so sorry about this, excuse me, Let us continue talk on Discord, also for faster responses from me, use my email hasanbayat1393@gmail.com

    Thanks.
     
  34. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi, sorry for my late, excuse me.
    We made a tutorial video for setting up PHP/MySQL:

    Thanks.
     
  35. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    There is no need to add SaveGameType_xxx to your custom types, it is just a pattern for calling your custom types and don't struggle other types.
    And for saving multiple data to one file, just make a wrapper data type and put other into that, then Save it using API, this is the easiest approach and makes your data handling easier.
    When you call SaveGame.Save("score", score) it creates a score file without any extension, that means you are providing the file name, not just an identifier, you might need to have a look at Identifiers section at documentation.

    Hope this helps.
    Thanks.
     
  36. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    New version submitted for Review, 2.4.3:
    • Fixed ReadInto Array Reading
    • Fixed Reading Custom Components and Types by using ReadSavableMembers and no ArgumentException will be thrown
    • Fixed Various bugs for saving and loading GameObjects
    In this version, we fixed most of the bugs and issues related to Saving and Loading GameObjects, in the next updates we will try to add a new window for specifying which Properties and Components to save and which to don't save.

    Thanks.
     
  37. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    921
    Hello there! @hasanbayat I just bought this a few minutes ago and wanted to ask a few questions. I am currently in process of testing out Master-Server Framework (using MongoDB) along with uMMO to make my RPG multiplayer, I was using Easy Save 2 while it was single player but since I will be doing things online now I started to look for something a bit better or my needs. I saw your system has MongoDB integration, so I picked it up.

    My questions is would this be something that I can perhaps run on the server side of things to maintain all the normal elements that an online RPG would have? Such as each players inventory, level, things they have unlocked, etc in an authoritive environment? I figure it is best to update and save everything directly from the server to the DB instead of trying to save anything from the client end. Would this have the flexibility to save things for each player to their own respective accounts? Is that even a good idea, or the best way to go about it?

    Thanks!
     
  38. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi.
    Yes, Save Game Pro has the capabilities you have mentioned above, but for more security and more possibilities, I would recommend you to customize the Server Side scripts of Save Game Pro to your needs and apply your security settings.
    Currently Save Game Pro has a very basic User authentication system, so you can use it if you are not looking for advanced one, but if you are looking for advanced one, go forward and make one (Also, don't hesitate to ask me for help) for your needs.
    Check out the example called Cloud Saving and Loading, that saves a simple string data type to a Database, and has a very basic user authentication system, use it as your own base and climb up to the advanced ones.
    Contact me via email (hasanbayat1393@gmail.com) for more help and more information about your needs.

    Thanks.
     
  39. DevStack

    DevStack

    Joined:
    Oct 7, 2014
    Posts:
    4
    Hello,

    I have a question for you. I've just started back game developing and I was looking at Save Game Pro as a way to handle my game saves/loads.

    Does it handle ScriptableObjects? According to the docs, it looks like it might, but I wanted to make sure.

    For example, at runtime I'm generating a series of "NPC" ScriptableObjects filled with random data and will need to save it out so when the player returns to the game save he/she gets the previously created NPCs.

    Thank you.
     
  40. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    921
    That is the beauty of scriptableobjects, they are essentially mini databases, they will save whatever you have in them. That being said, this definitely looks like a great asset. (I bought it, just have not implemented it yet.)
     
    DevStack likes this.
  41. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi.

    Yes it can, Save and Load even runtime generated ScriptableObjects.
    Let me know if you had issues for implementing this or you had any questions.
    I am currently working on to create more video tutorials to showcase the power of this package.

    Thanks.
    Best Regards.
     
    DevStack likes this.
  42. Kuhpik

    Kuhpik

    Joined:
    Dec 15, 2016
    Posts:
    4
    @hasanbayat

    Hello! I must say that you doing pretty good job, your asset is great!
    However i have a problem :c
    Can't serialize the Sprite in my scriptableobject. How can i solve this?
     
  43. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi.
    We glad you like it.
    Are you getting any errors? What is the issue? Can you explain more?

    Thanks.
     
  44. DevStack

    DevStack

    Joined:
    Oct 7, 2014
    Posts:
    4
    Very nice. Thanks for the quick reply. I'll be buying this later today to try it out!

    I just discovered ScriptableObjects recently and I'm in love. :)

    Thanks
     
    hasanbayat likes this.
  45. Kuhpik

    Kuhpik

    Joined:
    Dec 15, 2016
    Posts:
    4
    nevermind, this bug was only on my friend's pc. It works great on mine. Sorry for that ;D
     
  46. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    921
    Is it possible to use this to save the state of a game scene which can then be triggered by script? Meaning, I use the same scene for my server and client, when I do a server build I go into the scene and disable the menu, player ui, turn on the server side Enviro script, enable a prefab that has only the terrain collider, etc, then I build it. Once that is done, I do the opposite for a client build, I turn on the ui, turn off the server Enviro script, turn on the player script, turn off the terrain collider only prefab, etc.

    I am trying to make a one button build script, as of now if I select server, it automatically changes the target architecture and options, and whatnot uses a saved file name and path, etc. Same for client. If I could somehow use Save Game Pro to automatically trigger what items in the scene are enabled or disabled, that would complete the automation of my build.
     
  47. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    90
    I'd really like to save data_value data as human readable string. It's easier for me to handle it. Is this somehow possible?
    I'm using cloud save with php and mysql.
     
  48. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    921
    Hello,
    I have tried all three of the available ways to install the MongoDB extension and none of them work.

    When trying to use NPM I get this.

    Code (CSharp):
    1.  npm install savegamepro-mongodb --save
    2. npm ERR! Linux 4.4.0-116-generic
    3. npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "savegamepro-mongodb" "--save"
    4. npm ERR! node v4.2.6
    5. npm ERR! npm  v3.5.2
    6. npm ERR! code E404
    7.  
    8. npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/savegamepro-mongodb
    9. npm ERR! 404
    10. npm ERR! 404  'savegamepro-mongodb' is not in the npm registry.
    11. npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
    12. npm ERR! 404
    13. npm ERR! 404 Note that you can also install from a
    14. npm ERR! 404 tarball, folder, http url, or git url.
    15.  
    16. npm ERR! Please include the following file with any support request:
    17. npm ERR!     /root/npm-debug.log
    18.  
    When trying to download from git and run it, or from the zip, I either get this.

    Code (CSharp):
    1.  node app.js
    2. /root/savegame/node-savegamepro-mongodb-master/index.js:36
    3.   let action = module.exports.invalidAction;
    4.   ^^^
    5.  
    6. SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    7.     at exports.runInThisContext (vm.js:53:16)
    8.     at Module._compile (module.js:374:25)
    9.     at Object.Module._extensions..js (module.js:417:10)
    10.     at Module.load (module.js:344:32)
    11.     at Function.Module._load (module.js:301:12)
    12.     at Module.require (module.js:354:17)
    13.     at require (internal/module.js:12:17)
    14.     at Object.<anonymous> (/root/savegame/node-savegamepro-mongodb-master/app.js:6:21)
    15.     at Module._compile (module.js:410:26)
    16.     at Object.Module._extensions..js (module.js:417:10)
    17.  
    Or if I try and copy the config on git, I get this.

    Code (CSharp):
    1.  node app.js
    2. module.js:328
    3.     throw err;
    4.     ^
    5.  
    6. Error: Cannot find module '@bayatgames/savegamepro-mongodb'
    7.     at Function.Module._resolveFilename (module.js:326:15)
    8.     at Function.Module._load (module.js:277:25)
    9.     at Module.require (module.js:354:17)
    10.     at require (internal/module.js:12:17)
    11.     at Object.<anonymous> (/root/savegame/node-savegamepro-mongodb/app.js:3:21)
    12.     at Module._compile (module.js:410:26)
    13.     at Object.Module._extensions..js (module.js:417:10)
    14.     at Module.load (module.js:344:32)
    15.     at Function.Module._load (module.js:301:12)
    16.     at Function.Module.runMain (module.js:442:10)
    17.  
     
  49. eggeuk

    eggeuk

    Joined:
    Sep 1, 2013
    Posts:
    82
    Whats the Current Version Downloaded by Asset Store?
    Hello,
    these days I installed Save Game Pro. I got some troubles with Firebase, so I did a lookup for installed version.
    As the picture shows the download did install 2.1.8.
    But as above announced presently it should be 2.4.3
    So did I got the wrong version? And how can be done an update?
     

    Attached Files:

  50. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    921
    @hasanbayat Oh, I just looked.. I have 2.1.8 as well. What the? Though that doesn't explain the issues I am having in my post above a little bit, that was just on the server side.

     
    Last edited: Mar 26, 2018
unityunity