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

Is there any hacky way to keep data in editor after compiling without serialization?

Discussion in 'Editor & General Support' started by noanoa, Jan 29, 2019.

  1. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    I have a huge database in my game which doesn't change often. So, naturally, I want to keep it in memory to speed thngs up rather than getting the whole database deserialized/serialized every time assembly reloading happens in Unity Editor. (Actually, my database is an external file which is loaded manually when the game starts but it would be still better if I can keep it in editor memory and just set the reference to it when I enter play mode).

    Is there any way you can keep your non-serialized values/fields after your scripts are compiled in editor?
     
  2. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Hmm, I just tested with10x50MB of scriptable objects and while it takes ages to save/load the scene referencing them, it doesn't seem to slow down the time it takes to enter/leave play mode and upon assembly reloading. So, I guess in my case it might be better to just use scriptable objects for database rather than storing it externally and loading it manually.
     
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Why is the database so huge? And can you clarify, "loaded manually" what exactly are you loading? I suspect you are referring to large data file, and not a database?
     
  4. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Thanks for the reply. The database is arrays of some data structure and by saying "loaded manually" I meant deserializing manually by using fast serializer like protocol buffer. Anyway, the whole thing is to bypass serialization on domain reload so that I won't have to wait for 10+secs everytime a script is compiled etc.Scriptable objects seem to survive domain reload so I guess my problem is solved.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Or you could use an actual database that you don't need to load into memory at all! That is why I asked