Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

SaveIt - Save Load the whole scene or your own data

Discussion in 'Works In Progress - Archive' started by Marrrk, May 28, 2012.

  1. Marrrk

    Marrrk

    Joined:
    Mar 21, 2011
    Posts:
    1,032
    No, you dont need that.

    Do you save your data to a fixed filename ("MySave.dat") or a dynamic filename ("MySave" + slot + ".dat").

    When you know which filename to use, you can check wether the save exists or not.
     
  2. AMDAndrew

    AMDAndrew

    Joined:
    Aug 10, 2012
    Posts:
    90
    Code (csharp):
    1.  
    2. #pragma strict
    3. import SaveIt;
    4.  
    5. var Mouse : boolean = false;
    6.  
    7. function OnMouseEnter()
    8. {
    9.     Mouse = true;
    10. }
    11.  
    12.  
    13. function OnMouseExit()
    14. {
    15.     Mouse = false;
    16. }
    17.  
    18. function Update () {
    19.  
    20.     if( Input.GetMouseButton(0)  Mouse == true){
    21.         LoadScene();
    22.         }
    23.  
    24. }
    25.  
    26. function LoadScene(saveName : String)
    27.  
    28. {
    29.     var context : LoadContext = LoadContext(saveName);  
    30.     Scene.Load(context);
    31. }
    32.  
    Will this work ?
     
    Last edited: Oct 10, 2012
  3. krougeau

    krougeau

    Joined:
    Jul 1, 2012
    Posts:
    451
    Wow! SaveIt sounds quite flexible. I'll be trying it out on my current project this afternoon and will pop back by when I have some feedback. The "load and save the entire scene" function sounds like exactly what I need for another screwy project idea I came up with last night, so I'm all excited to test it :) Keep up the great work!
     
  4. alan-lawrance

    alan-lawrance

    Joined:
    Feb 1, 2013
    Posts:
    354
    Can anyone confirm if SaveIt works on iOS, specifically iPad?
     
  5. sholeh13

    sholeh13

    Joined:
    Jan 10, 2013
    Posts:
    1
    hi
    I first import saveit, why logging out like this ?

    and
     
  6. Marrrk

    Marrrk

    Joined:
    Mar 21, 2011
    Posts:
    1,032
    The first error suggests that there is more than one class/struct/type with the Name UniqueIdentifier present in your project. Did you or any other asset create a type with this name?

    The second error seems to be the result of the first problem.
     
  7. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Hi, this is a great project and I am interested.

    Question: Does this work on IOS, Android, Web Player?

    btw, IOS does not like LINQ . The less LINQ the more likely that it will work on IOS.

    Would definitely buy right away if it works on MOBILE.
     
    Last edited: Jun 28, 2013
  8. Marrrk

    Marrrk

    Joined:
    Mar 21, 2011
    Posts:
    1,032
    Hi there,

    people reported that it will not work on IOS, due to AOT compile problems, maybe because of some linq statements.

    You can check it for yourself, there exists a free version of SaveIt :)
     
  9. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    I bought the pro Version to test because the Free version hasn't been updated since 2012.

    Please check the Private Message. I ran into errors from the example3 and from a scene where I'm only saving a sphere.
    The Errors are just using my desktop. I haven't tested on IOS yet.
     
  10. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    This is the last message that I sent in PM.

    Hi Marrrk,

    I've just tested SaveIt within my project. Here are the steps that I took.

    1. Setup using the SaveIt assistant.
    2. Added Saveable comp to simple sphere in the project.
    3. Saved the scene. No Errors.
    4. Load Scene, 2 info, 1 errors.

    ----------- Info 1 ------------------------

    Sphere found parent: MODEL-01
    UnityEngine.Debug:Log(Object)
    SaveIt.TypeSerializer.Unity.Component.TransformSer ializer:grin:eserialize(Type, LoadContext)
    SaveIt.LoadContext:LoadTableEntry(TableEntry, Object)
    SaveIt.LoadContext:Load(Int32, Object)
    SaveIt.LoadContext:LoadToInstance(String, Object)
    SaveIt.LoadContext:LoadToInstance(String, Component)
    SaveIt.TypeSerializer.Unity.GameObjectSerializer:grin:eserialize(Type, LoadContext)
    SaveIt.LoadContext:LoadTableEntry(TableEntry, Object)
    SaveIt.LoadContext:Load(Int32, Object)
    SaveIt.LoadContext:Load(Int32)
    SaveIt.LoadContext:ConvertReferenceArray(Array, Array, Int32, List`1)
    SaveIt.LoadContext:LoadValueObject(Property)
    SaveIt.LoadContext:Load(String)
    SaveIt.LoadContext:Load(String, Action`1)
    SaveIt.TypeSerializer.ClassSerializer:grin:eserializeMembers(Object, LoadContext, IEnumerable`1)
    SaveIt.TypeSerializer.ClassSerializer:grin:eserialize(Type, LoadContext)
    SaveIt.LoadContext:LoadTableEntry(TableEntry, Object)
    SaveIt.LoadContext:Load(Int32, Object)
    SaveIt.LoadContext:Load(Int32)
    SaveIt.LoadContext:LoadReferencableObject(Property )
    SaveIt.LoadContext:Load(String)
    SaveIt.LoadContext:Load(String)
    SaveIt.Scene:OnLevelLoaded(LoadContext, GameObject)
    SaveIt.<>c__DisplayClass1:<Load>b__0()
    SaveItComponent:Update()

    ------------ Info 2 --------------------------------

    Error while handling element 'Key':
    SaveIt.Scene (SaveIt.Scene)
    Sphere (UnityEngine.GameObject) (UnityEngine.GameObject)
    Sphere (Saveable) (Saveable)
    System.Collections.Generic.List`1[System.Collections.Generic.KeyValuePair`2[System.Type,System.Collections.Generic.List`1[System.String]]] (System.Collections.Generic.List`1[[System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Collections.Generic.List`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]])
    ()
    ()


    UnityEngine.Debug:Log(Object)
    SaveIt.ContextBase:LogException(Exception)
    SaveIt.LoadContext:Load(String)
    SaveIt.LoadContext:Load(String)
    SaveIt.Scene:OnLevelLoaded(LoadContext, GameObject)
    SaveIt.<>c__DisplayClass1:<Load>b__0()
    SaveItComponent:Update()


    ------------Error 1 --------------------------------------

    MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.MonoType'.
    System.Activator.CreateInstance (System.Type type, Boolean nonPublic) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System/Activator.cs:36:cool:
    System.Activator.CreateInstance (System.Type type) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System/Activator.cs:254)
    SaveIt.TypeSerializer.ClassSerializer.Deserialize (System.Type type, SaveIt.LoadContext context)
    SaveIt.LoadContext.LoadTableEntry (SaveIt.TableEntry target, System.Object instance)
    SaveIt.LoadContext.Load (Int32 index, System.Object instance)
    SaveIt.LoadContext.Load (Int32 index)
    SaveIt.LoadContext.LoadReferencableObject (SaveIt.Property property)
    SaveIt.LoadContext.Load (System.String name)
     
  11. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Hi Marrrk,

    Did you get a chance to see what the problem might be ?
    I still cannot get the Example3 to work and still having the same errors above. From all of your descriptions of how great SaveIt is, I got very excited and bought the package hoping that it does what it was advertised to do.

    Thanks.
     
  12. Marrrk

    Marrrk

    Joined:
    Mar 21, 2011
    Posts:
    1,032
    Hi there, now I have time to look into this issue. You just created a simple scene with a unity default sphere and a camera, right?
     
  13. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Hi Marrrk,

    The project is a simple scene.

    Also, the Example3 that's included with the package got the same error. Please see my previous post.
     
  14. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Hi, Did you find out what the problem might be?
     
  15. Marrrk

    Marrrk

    Joined:
    Mar 21, 2011
    Posts:
    1,032
    I working on it :)
     
  16. Marrrk

    Marrrk

    Joined:
    Mar 21, 2011
    Posts:
    1,032
    I was not able to reproduce this error, could you send me your whole scene (including SaveIt), maybe so I am able to see what the problem is.
     
  17. FahmiHasan

    FahmiHasan

    Joined:
    Jan 9, 2013
    Posts:
    4
    Hello Marrrk,
    first of all i would say thank you for making this plug in available for Unity.
    Anyway i'm new on coding and I use Javascript for my game.
    I also facing a problem using SaveIt.
    Basically, my scene is consist of one cube with score script (wrote on Javascript) and also Saevable script from SaveIT plug in attached.
    And when i press space, the score is added by 10, thats all

    Using script from aixaix (as seen on page 2 of this thread), i try to save my game.
    i got error like this:

    Error while handling element '[Scene]':
    SaveIt.Scene (SaveIt.Scene)

    NullReferenceException
    UnityEngine.GameObject.GetComponent[SaveItComponent] () (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/UnityEngineGameObject.cs:27)

    can you help me to figured out whats wrong?
    kind regards
     
  18. Marrrk

    Marrrk

    Joined:
    Mar 21, 2011
    Posts:
    1,032
    Hi there, you try to save the entire scene, but your scene is missing the SaveItComponent on one of your GameObjects (there shopuld be a special GO only for this). SaveIt will create this GO and Component automatically. But for this to work you need to activate the saveit scene support, in one of the menus there should be a menuitem specially for this.
     
  19. Skyvader

    Skyvader

    Joined:
    Jul 22, 2013
    Posts:
    1
    Hi Marrrk,
    I was working whit saveIt and i got some issues.
    I was looking to Example 3 and i notice this component $Image1.jpg

    Where it comes from. If i remove it form the objects that has saveable script on them i cannot load and i get the following error:
    MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.MonoType'.
    System.Activator.CreateInstance (System.Type type, Boolean nonPublic) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System/Activator.cs:368)
    System.Activator.CreateInstance (System.Type type) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System/Activator.cs:254)
    SaveIt.TypeSerializer.ClassSerializer.Deserialize (System.Type type, SaveIt.LoadContext context)
    SaveIt.LoadContext.LoadTableEntry (SaveIt.TableEntry target, System.Object instance)
    SaveIt.LoadContext.Load (Int32 index, System.Object instance)
    SaveIt.LoadContext.Load (Int32 index)
    SaveIt.LoadContext.LoadReferencableObject (SaveIt.Property property)
    SaveIt.LoadContext.Load (System.String name)

    When i tried it on my proyect that component did not create automatically using window/saveit/setup scene assistent, how should i create it or i need the pro version?
     
  20. DaCreeperRhaxx

    DaCreeperRhaxx

    Joined:
    Apr 6, 2013
    Posts:
    1
    i got the thingy off the asset store but i don't know which one to use. My game is a physics game with shooting blocks (cubes) and playing around with the toys but which one to use???????????????????

    thanks
    Katfish
     
  21. GoodEnoughGames

    GoodEnoughGames

    Joined:
    Jun 2, 2013
    Posts:
    66
    This is fantastic, just saved me a whole bunch of coding :)

    -Tom
     
  22. awwolfe

    awwolfe

    Joined:
    Sep 22, 2013
    Posts:
    27
    Thanks for the free plugin, but I am having an issue that I was hoping you could help with.....

    I am having issues on PC when trying to use my own filename (it won't create a new file). Can this be done? Eventually, I would like to be able to create a dynamic filename , so couldn't just set up files ahead of time. Below is just an example of what I'm getting from " context = LoadContext.FromFile(FileName);" where filename="Players.dat"

    FileNotFoundException: Could not find file "C:\Users\Tony\Documents\bikeSingleTest\Players.dat"
    System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Applications/buildAgent/work/c514da0c8183631c/mcs/class/corlib/System.IO/FileStream.cs:320)
    System.IO.FileStream..ctor (System.String path, FileMode mode)
    (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode)
    SaveIt.TableSerializer.File.Deserialize ()
    SaveIt.LoadContext..ctor (ITableSerializer tableSerializer, SaveIt.ResourceEntry[] resourceEntries)
    SaveIt.LoadContext.FromFile (System.String path)
    ChoosePlayer.LoadPlayers () (at Assets/Scripts/GuiStuff/ChoosePlayer.cs:76)
    ChoosePlayer.Start () (at Assets/Scripts/GuiStuff/ChoosePlayer.cs:21)
     
  23. awwolfe

    awwolfe

    Joined:
    Sep 22, 2013
    Posts:
    27
    The space in the FileNotFoundException is only in the post. Players.dat has no space, but is showing on this post for some reason. So not the source of the problem.
     
  24. Runemark

    Runemark

    Joined:
    May 23, 2013
    Posts:
    244
    Hi! I had a same error, when I tried to save the whole scene. Now I tried to save the game objects one-by-one, and I got the following error:

    I want to save a simple cube with material.
    $cube.jpg

    My script what is called if I press the "Save" button:

    Code (csharp):
    1.  
    2. private void Save()
    3.     {
    4.         SaveContext context;
    5.         if (Application.isWebPlayer)
    6.             context = SaveContext.ToPlayerPrefs(FileName);
    7.         else
    8.             context = SaveContext.ToFile(FileName);
    9.  
    10.         Debug.Log("Savind: " + myGameObject.name);
    11.         context.Save(myGameObject);
    12.         Debug.Log("Save Done");
    13.     }
    14.  
    (myGameObject is a class variable, and I gave the right object via inspector.)


    The error, what I get at save:
    No .dat created...
     
  25. FreeTimeDev

    FreeTimeDev

    Joined:
    Jul 7, 2012
    Posts:
    64
    Are there any plans to update this asset? I'm using Example3 from the basic version and it errors out on loading.

    Code (csharp):
    1. MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.MonoType'.
    2. System.Activator.CreateInstance (System.Type type, Boolean nonPublic) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Activator.cs:368)
    3. System.Activator.CreateInstance (System.Type type) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Activator.cs:254)
    4. SaveIt.TypeSerializer.ClassSerializer.Deserialize (System.Type type, SaveIt.LoadContext context)
    5. SaveIt.LoadContext.LoadTableEntry (SaveIt.TableEntry target, System.Object instance)
    6. SaveIt.LoadContext.Load (Int32 index, System.Object instance)
    7. SaveIt.LoadContext.Load (Int32 index)
    8. SaveIt.LoadContext.LoadReferencableObject (SaveIt.Property property)
    9. SaveIt.LoadContext.Load (System.String name)
    10.  
     
  26. Sparty

    Sparty

    Joined:
    Aug 26, 2010
    Posts:
    82
    Has anyone tested this in linux? Works?

    Thanks,
    -Eric
     
  27. Elsammak

    Elsammak

    Joined:
    Nov 11, 2013
    Posts:
    9
    It give me error "JIT" while running on iPhone, but works well on android,
     
  28. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,511
    Ok when I use Saveable script on the prefab and bring it into the scene it loses all the setting and resets to saving everything.


    Clearly, this can't work like this as you can't be setting what to save per object if you have 100s of them.

    How can I get around this issue?