Search Unity

Easy Save - The Complete Save Data & Serialization Asset

Discussion in 'Assets and Asset Store' started by JoelAtMoodkie, May 28, 2011.

  1. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Ah my apologies, yes there is, though no coding is required. You need to go to Assets > Easy Save 2 > Manage Types and add your custom types there (more info can be found in the Automatically adding support for a type guide).
     
    luniac likes this.
  2. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    Hmm it says Easy Save can add support for types which provide a parameterless constructor, and can support properties which are:
    • Public
    • Non-static
    • Allows reading and writing
    • Is currently supported by Easy Save

    Does this mean i can't save JS scripts, i don't think they have a constructor.
    Also I'm not sure what you mean by properties, can my script use private variables?
     
  3. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Component scripts are supportable by default (regardless of whether you coded them in JS or C#). Take a look at it in Manage Types to see what properties in the Component are supportable.

    Properties are the variables of the script. Private properties aren't supportable because there's no way to access private properties without breaking polymorphism (the point of private variables is so that you can't access them). The only way to save these would be to add public Save() and Load() methods to your script (which will be able to access the private variables) which you can call whenever you want to save or load.

    i.e. Script1 could look like this:

    Code (CSharp):
    1. public class Script1 : MonoBehaviour
    2. {
    3.     private int privateInt = 123;
    4.     private bool privateString = "myString";
    5.  
    6.     // Use this for initialization
    7.     public void Save (string filename)
    8.     {
    9.         ES2.Save(privateInt, filename+"?tag=myPrivateInt");
    10.         ES2.Save(privateString, filename+"?tag=myPrivateString");
    11.     }
    12.    
    13.     // Update is called once per frame
    14.     void Load (string filename)
    15.     {
    16.         privateInt = ES2.Load<int>(filename+"?tag=myPrivateInt");
    17.         privateString = ES2.Load<string>(filename+"?tag=myPrivateString");
    18.     }
    19. }
    And then to save and load a Script1 in your Game Manager, you'd just call the Script1's Save and Load methods.
     
  4. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    ok thanks i think i understand the approach. I didn't realize all the types are in the manage types window, i was only looking at the web guides.

    One more question,after i load the script:
    ES2.Load<Script1> ("myFile.txt?tag=script1", script1);

    The script will call it's Awake() and Start() methods upon being loaded into the variable?
    so that i can call the Load function to load it's private variables.
     
  5. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    If you're adding Save and Load methods to Script1, you don't use ES2.Save and ES2.Load to save and load it. Instead you simply call the Script1's Save and Load methods (as these methods will contain your ES2.Save and ES2.Load methods).

    Also just to clarify, when using the ES2.Load method which takes a second parameter (known as self-assigning load), it doesn't create a new Component, it simply assigns the values to the Component you specify as a second parameter. So Awake and Start won't be called when using that method.

    If you don't specify the second parameter, then it will create a new Script1 and return it, and Start/Awake will be called. i.e.
    Code (CSharp):
    1. Script1 script1 = ES2.Load<Script1>("myFile.txt?tag=script1");
    However, as a Component cannot exist without a GameObject to attach it to, it will also create a temporary GameObject.

    All the best,
    Joel
     
    luniac likes this.
  6. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    AHHH ok its clear now,
    So it can all be done in the main script.
    1 line of code to load the script into the component reference.
    1 line of code to call the load functions withing the now existing component reference.
     
  7. Kellyrayj

    Kellyrayj

    Joined:
    Aug 29, 2011
    Posts:
    936
    Hi @joeltebbett

    Does Easy Save support the import a previously saved csv? I am not finding any documentation of something like this on your website.
     
  8. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    This is not currently supported but there's a feature request you can vote on HERE.

    In the meantime you can get the values from a CSV files by doing something like this:

    Code (CSharp):
    1. // Get the CSV file as a string.
    2. string csv = System.Text.Encoding.UTF8.GetString(ES2.LoadRaw("myFile.csv"));
    3. // Get the rows from the string.
    4. string[] rows = csv.Split('\n');
    5. // Get the individual values from each row.
    6. foreach(string row in rows)
    7.     string[] rowStrings = row.Split( ',' );
    This assumes than none of your values contain commas or newlines.

    All the best,
    Joel
     
    Kellyrayj likes this.
  9. MattBradley

    MattBradley

    Joined:
    Nov 8, 2013
    Posts:
    11
    Hey I'm having an issue where I'm unable to add a tag to a file using the ES2 File Editor.

    When trying to save a System.String tag I get the following error:
    Code (CSharp):
    1. MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.String'.
    2. System.Activator.CreateInstance (System.Type type, Boolean nonPublic) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Activator.cs:368)
    3. System.Activator.CreateInstance (System.Type type) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Activator.cs:254)
    4. ES2EditorType.CreateInstance ()
    5. ES2EditorFileEditor.AddTag (System.String tag, System.Type type)
    6. ES2EditorFileEditor.DisplayAddNewTag ()
    7. ES2EditorFileEditor.DisplayTagList ()
    8. ES2EditorFileEditor.DisplayGUI ()
    9. ES2EditorFileEditor.OnGUI ()
    10. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Am I missing something?
     
  10. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi Matt,

    Are you using the latest version of Easy Save? There was a bug which caused this in an earlier version but was fixed, and is working for us in the current version.

    All the best,
    Joel
     
  11. MattBradley

    MattBradley

    Joined:
    Nov 8, 2013
    Posts:
    11
    Ah, I probably ought to have checked that first! Works perfectly. Thanks for the super speedy support and a great asset :)
     
    JoelAtMoodkie likes this.
  12. marcos

    marcos

    Joined:
    Oct 18, 2009
    Posts:
    592
    Hi Joel,

    Just bumping this to let you know that Playmaker 1.8 is now live. :D!

    Eagerly awaiting array upload and download.

    Many thanks,
    Mark
     
  13. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    That's great to hear Mark. I've pushed adding support for Playmaker arrays to the top of our To Do list, so assuming we don't run into any major difficulties it should be in the next version.

    All the best,
    Joel
     
    hopeful likes this.
  14. marcos

    marcos

    Joined:
    Oct 18, 2009
    Posts:
    592
    Legend! Thanks, mate!
     
  15. cesarpo

    cesarpo

    Joined:
    Jun 8, 2013
    Posts:
    97
    Hi, just bought the package, everything seems to be working.

    But I would like to see/edit my custom types in the file editor:

    upload_2016-5-30_21-24-26.png

    With the custom type looking like this:

    Code (CSharp):
    1. public class PocketData
    2. {
    3.     public DateTime Created;
    4.     public DateTime Updated;  
    5.     public int Amount;      
    6. }
    Is it possible for me to manually add support for it?
     
  16. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    Although we don't officially support the ability to view custom types in the file editor, you may be able to add support by creating your own ES2EditorType containing Unity Editor GUI code to display your fields, and putting it in Assets/Plugins/Editor.

    Here's the ES2EditorType for the Transform class which should hopefully allow you to see how you could add support for your own custom class:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using System.Collections;
    4.  
    5. public class ES2Editor_Transform : ES2EditorType
    6. {
    7.     public ES2Editor_Transform() : base(typeof(Transform)){}
    8.    
    9.     public override object DisplayGUI(object data)
    10.     {
    11.         Transform c = (Transform)data;
    12.         c.position = EditorGUILayout.Vector3Field("Position", c.position);
    13.         c.eulerAngles = EditorGUILayout.Vector3Field("Rotation", c.rotation.eulerAngles);
    14.         c.localScale = EditorGUILayout.Vector3Field("Local Scale", c.localScale);
    15.         EditorGUILayout.LabelField("Tag");
    16.         c.tag = EditorGUILayout.TextField(c.tag);
    17.         return c;
    18.     }
    19. }
    All the best,
    Joel
     
  17. madpoet0204

    madpoet0204

    Joined:
    Sep 10, 2012
    Posts:
    98
    Loving Easy Save 2! easy to use and very powerful!

    I need to append to a spreadsheet file and the docs suggest to define append as true but not sure where
    to define that. Code is below:

    varsheet : ES2Spreadsheet = newES2Spreadsheet();

    sheet.SetCell(0, 0, "someData"); sheet.SetCell(1, 0, "otherData");

    sheet.Save("mySheet.csv");
     
  18. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    You just need to set the append field of the ES2Spreadsheet object to true. i.e.

    Code (CSharp):
    1. sheet.append = true;
    All the best,
    Joel
     
  19. madpoet0204

    madpoet0204

    Joined:
    Sep 10, 2012
    Posts:
    98
    Perfect!


    Great plugin!
     
  20. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251
    Hi @joeltebbett
    Used ES2 for ages now and still love it.
    Quick question, can it or will it support cloud saving? And if not, can you recommend a plugin or method for saving file to the cloud. Want to release on Apple TV, but have to do cloud saving for that device, so may as well do it for all devices.
    Thanks!
     
  21. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there, glad you're enjoying Easy Save!

    We actually have a feature request for tvOS support here which you can vote on. We'll definitely be adding support for it in the future, but how soon we add support depends on how much demand there is for it. Because it'll require us to buy new hardware and write plugins in native Obj-C/Swift, it's quite a lot of work, so we'd need more votes before being able to add it.

    At current however, you should be able to set the save location to PlayerPrefs to save locally. i.e.

    Code (CSharp):
    1. ES2.Save(123, "myFile.txt?tag=myTag&savelocation=playerprefs");
    2.  
    3. int myInt = ES2.Load<int>("myFile.txt?tag=myTag&savelocation=playerprefs");
    Although we're not allowed to recommend external cloud plugins for legal reasons, any plugin which works with byte arrays should work. You can write your data to memory using an ES2Writer, and then get the data as a byte array (which you should be able to upload to the cloud) using the stream.GetAllBytes() method. i.e.

    Code (CSharp):
    1. using(ES2Writer write = new ES2Writer("myFile.txt?savelocation=memory"))
    2. {
    3.     // Write your data.
    4.     writer.Write(123, "myInt");
    5.     writer.Write(transform, "myTransform");
    6.     // Get the data as a byte array, which you can upload to the cloud.
    7.     byte[] bytes = writer.stream.ReadAllBytes();
    8. }
    And then to read data from a byte array, you can use the ES2Reader(byte[] bytes) constructor. i.e.

    Code (CSharp):
    1. using(ES2Reader reader = new ES2Reader(bytes))
    2. {
    3.     int myInt = reader.Read<int>("myInt");
    4.     reader.Read<Transform>("myInt", transform);
    5. }
    All the best,
    Joel
     
    OceanBlue likes this.
  22. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251
    Thanks very much for this.
    I'd put a +1 on the vote if I could, but for some reason, can't recall my password for the site, nor my user name and hence can't retrieve my password via email :<

    Thanks for your help on the above.
     
  23. madpoet0204

    madpoet0204

    Joined:
    Sep 10, 2012
    Posts:
    98
    I tested out EasySave on my mac and it's working great, but when I made a package of a scene to make
    a spreadsheet and imported into my PC, I get a
    "The thing you want to instantiate is null" report in the console.

    Any suggestions?

    EASY SAVE IS EXCELLENT!
     
  24. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    Glad you've found Easy Save useful!

    With regards to the error you're getting: did you export the 'Assets/Easy Save 2' folder with it too? The only thing I can think of which could cause this error is if the ES2Init prefab is missing in 'Assets/Easy Save 2/Resources/Easy Save 2'.

    Do you get any other errors to console before this, or is there any other information regarding where the error occurred?

    All the best,
    Joel
     
  25. madpoet0204

    madpoet0204

    Joined:
    Sep 10, 2012
    Posts:
    98
    aaaah!
    So I re-installed the original easysave package and it's all good :)
    Thx for the quick reply!
     
    JoelAtMoodkie likes this.
  26. aaronjbaptiste

    aaronjbaptiste

    Joined:
    Dec 4, 2012
    Posts:
    62
    Hi Joel,

    Really impressed with Easy Save so far! great job.

    Quick question, i'm having trouble saving a custom class, it has a generic type like:

    Code (CSharp):
    1.  
    2. public class MyClass<T>
    3. {
    4.     public T[] data;
    5.    ...
    6. }
    7.  
    It doesn't appear in the Manage Types window, so I created a manual entry for it in ES2Init (including information about the Type):

    Code (CSharp):
    1.  
    2. ES2TypeManager.types[typeof(MyClass<int>)] = new ES2UserType_MyClass();
    3.  
    This works fine, save and load all good. The problem is when ES2Init is refreshed, it gets transformed into this:

    Code (CSharp):
    1.  
    2. ES2TypeManager.types[typeof(MyClass`1[int])] = new ES2UserType_MyClass();
    3.  
    Which of course causes a compiler error and I need to change it back manually.

    Any tips on how to get around this? How does it work internally for Collection types (which use generics), maybe I can use the same method.

    Thanks!
     
  27. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    This appears to be a small bug at our end. If you PM me your email and invoice number, I'll get a fixed version sent out to you. The fix will also be included in the next update.

    All the best,
    Joel
     
  28. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    To manually uninstall Easy Save, follow the following steps:
    1. If you're using the Auto Save functionality, remove Auto Save from your scenes and project by going to the Window > Easy Save 2 > Auto Save > Settings and select Remove Auto Save from Scene and Remove Auto Save from Project.
    2. If you're using the Playmaker functionality, delete the action located at /Assets/Playmaker/Actions/ES2Playmaker.cs.
    3. Delete the /Assets/Easy Save 2/ folder.
    4. Delete ES2.dll and MoodkieSecurity.dll from /Assets/Plugins/ and any subfolder within that folder (i.e. WSA, WP8, Metro, UWP).
    All the best,
    Joel
     
  29. Atomic_Raccoon

    Atomic_Raccoon

    Joined:
    Apr 13, 2016
    Posts:
    3
    Hi Joel,

    - I've created a new Class, that inherit from Monobehaviour. There's a constructor inside.

    Code (CSharp):
    1.  
    2. public class aClass : MonoBehaviour
    3. {
    4. public float time;
    5. public int totalNumber;
    6.  
    7. public LvlSaveInfo(float newTime, int newTotalNumber)
    8. {
    9. time=newTime;
    10. totalNumber=newTotalNumber;
    11. }
    12. }
    13.  
    - Then I've created a dictionary using this classe
    Code (CSharp):
    1.  
    2. Dictionary<string, aClass> myDictionary = new Dictionary<string, aClass>();
    3.  
    - I've add a new entry in that dictionary:
    Code (CSharp):
    1.  
    2. aClass newClass = new aClass(20f, 10);
    3. myDictionary.Add("something", newClass);
    4.  
    - Finally I've tried to save and load this dictionary using
    Code (CSharp):
    1.  
    2. ES2.Save<string,aClass>(myDictionary,"SomeTextFile");
    3.  
    - Unfortunately, I can't use my constructor using a Monobehaviour inheritance (Unity tells me that I have to use AddComponent), And I can't use EasySave if the class doesn't inherit from Monobehaviour.

    How can I solve my problem? I've seen you said something about a parameterless constructor, but I don't understand what it is.

    Best,

    Edouard
     
  30. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi Edouard,

    Classes do not need to inherit from MonoBehaviour to be serializable by Easy Save. I've just tested your class (without the inheritance from MonoBehaviour) and it appears to be working fine for me.

    If you're receive any errors, let me know and I'll take a look at what the problem is.

    All the best,
    Joel
     
  31. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    Question... is this link.xml file (content below) that gets dumped in the root of the project you guys? It really hurts my OCD.

    Code (csharp):
    1.  
    2. <linker>
    3.        <assembly fullname="mscorlib">
    4.                 <namespace fullname="System.Security.Cryptography" preserve="all"/>
    5.                 <namespace fullname="System.IO.Directory" preserve="all"/>
    6.        </assembly>
    7. </linker>
    8.  
     
  32. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi Steve,

    That is indeed us. Unity requires that there's a link.xml file in the Assets folder to prevent important classes from being stripped on Android and in IL2CPP. If you're using neither of these, it's safe to delete.

    All the best,
    Joel
     
  33. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    Thanks Joel.
     
  34. Atomic_Raccoon

    Atomic_Raccoon

    Joined:
    Apr 13, 2016
    Posts:
    3
    Thanks Joel for your prompt reply. I still have this error message (That's why I thought the class had to inherit from Monobehaviour) :

    Assets/Easy Save 2/Types/ES2UserType_aClass.cs(24,36): error CS0309: The type `aClass' must be convertible to `UnityEngine.Component' in order to use it as parameter `T' in the generic type or method `ES2Type.GetOrCreate<T>()'
     
  35. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    It looks like when you generated the ES2Type using Manage Types it was a MonoBehaviour, but you've since changed it so that it's not. If you go back into Manage Types and regenerate the ES2Type for the class, it will generate the correct ES2Type for a class.

    All the best,
    Joel
     
    Atomic_Raccoon likes this.
  36. Atomic_Raccoon

    Atomic_Raccoon

    Joined:
    Apr 13, 2016
    Posts:
    3
    It works like a charm now. Thanks Joel!
     
  37. itfcjim

    itfcjim

    Joined:
    Mar 3, 2014
    Posts:
    5
    Hi Joel

    I've started to look at implementing Easy Save into one of my projects. I'm going to need to save/load custom types so I'm looking in Assets -> Easy Save 2 -> Manage Types...

    I can only see classes in there that are at the top level in the namespace (i.e. not the ones that are inside other classes, even if they're public) - is that by design, and is there any way around it?

    We're at an early stage in the project so moving them around isn't a problem, however when I've moved them to the top level they don't always appear in the Manage Types dialog. I've tried clicking "Refresh ES2Init" to no avail and end up having to restart Unity to get them to appear. Is there another way to trigger a refresh of this dialog?

    Looking promising so far, keep up the good work

    Cheers
    Jim
     
  38. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    By design, it's not possible to automatically generate ES2Types for nested classes as there's certain situations where this can cause undesired behaviour.

    However, you may be able to manually add support for it. If you change the class so that it's not nested, generate the ES2Type for that class, and then re-nest it, it should just be a case of changing the ES2Type so that it uses the nested class name instead of the un-nested one (the ES2Type is located in Assets/Easy Save 2/Types/ with the name ES2UserType_TypeName.cs).

    With regards to the type list not refreshing, unusually we don't seem to be getting this behaviour at our end. It sounds like it might be caching the window, in which case calling this from an editor script should manually refresh it:

    Code (CSharp):
    1. ((ES2EditorManageTypes)EditorWindow.GetWindow (typeof (ES2EditorManageTypes))).Awake();
    All the best,
    Joel
     
  39. itfcjim

    itfcjim

    Joined:
    Mar 3, 2014
    Posts:
    5
    Cheers Joel

    I had an error in one of my scripts which I think was causing the dialog to not refresh. All sorted now

    Thanks for the tip on the nested classes, had a look at how it hangs together now and looks easy to do

    We are looking at forward-compatibility of saved objects between versions and saw this forum post: http://www.moodkie.com/forum/viewtopic.php?f=5&t=1088 - do you have a timeline for the v3.0 beta, would be curious to try it out!

    Cheers
    Jim
     
  40. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi Jim,

    We're aiming at the beginning of February for the Easy Save 3 beta, assuming we don't run into any major pitfalls between now and then :)

    All the best,
    Joel
     
  41. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    How do I unload data, but not delete the data file?

    Like if I have used ES2.LoadAll and assigned that to es2data variable, do I just do Destroy(es2data)?

    If so, will any variables that reference data (tags) from es2data need to be nulled first, or will Destroying only es2data take care of all memory?
     
    Last edited: Jan 21, 2017
  42. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    ES2Data is garbage collected just like any other managed resource. If you've loaded a Component using LoadAll, an ES2 Loaded Component GameObject will be created and the loaded component will be attached to this ... these will not be destroyed when you dispose of the ES2Data. Other reference fields in the ES2Data act the same as any other class (I.e. They will get garbage collected unless you reference them from a variable elsewhere).

    All the best,
    Joel
     
  43. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    So, in order to remove data, I would have to get the ES2 Loaded Component gameObject and destroy it? But how do I get the object? The component doesn't have the normal someComponent.gameObject code option.
     
  44. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    and also, if I have a ES2data component, and a reassign it and load in another ES2data file, what happens? Does the ES2 component just take on the new data(hopefully), does it do anything to the ES2data object? Does it create another ES2 object with the same component?
     
  45. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    Components should have a gameObject field (see https://docs.unity3d.com/ScriptReference/Component.html). If it's not appearing for you, you may want to contact Unity as it will be a bug at their end.

    LoadAll will create a new instance of your Component each time, as Unity provides no way of storing references. For this reason, it is advised that you load Components using self-assigning Load instead, which allows you to provide a reference to a Component which you want to load the data into (http://docs.moodkie.com/easy-save-2/api/es2-load/).

    All the best,
    Joel
     
  46. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    Are you sure were on the same idea? Maybe I'm doing something wrong. I get " 'ES2Data' does not contain a definition for 'gameObject' " it's not in the docs either. I figured maybe just because that's a common function it wasn't written into ES2 docs.

    Thanks for your the help on this
     
  47. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    The ES2Data object is not the loaded component, it's just a Dictionary which contains the loaded data. You will need to get the GameObject of the loaded component itself.

    All the best,
    Joel
     
  48. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    So what is the best approach to offload data created at start of game to file at runtime, loaded in at runtime as needed, without deleting the file? I am trying to load/unload lots of Vector3, ints, and floats data as the player moves around the world to manage memory. Once the game is over, I delete these temporary files.
     
  49. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Sorry, I don't quite understand what you mean regarding "without deleting the file". Would you be able to elaborate?
     
  50. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    Maybe deleting the file wouldn't work either, since the data is already loaded into GameObjects... so nvm that.

    How can I unload this data in memory after loading it - is basically what I'm trying to figure out.

    I have a separate files created with ES2 per player area, and want to only have loaded in the relevant files, and unload no longer relevant data, but I would need to get rid of the component/objects that have the data(and this is the part i'm confused about).

    So your saying to use Load instead of LoadAll, so that I can choose where it is assigned. So if I point to a specific script component and load the data I want, to corresponding variables within said script component, I can delete said script components GameObject to remove data (so long as the data is no longer referenced in any components variables and do UnloadUnusedAssets or GC)?

    Edit: and if that scenario is doable, what about if I instead of destroying the game object, I reassign its component variables to the new data I want to load(from another ES2 file), would the previous data then be freed from memory, or would the previous ES2 file still be in memory?

    I'm hope I'm not sounding crazy