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.

BG Database (inMemory database | Excel/Google Sheets syncing | CodeGen | Save/Load support)

Discussion in 'Assets and Asset Store' started by BansheeGz, May 3, 2018.

  1. SoftwareGeezers


    Jun 22, 2013
    Yeah, I caught the import wizard. It's a separate "DB construct process". Though I'd prefer the spreadsheet to be more visibly informative, it's not too bad. If I move to custom IDs, I can use those like GDEditor.

    A couple of questions about Save/Load -
    I'm not sure what this means. Does that mean I can't do what I'm asking for above, have references to tables/fields, if using dynamic data?

    Also is there a 'backup' of the original data so that I can restore to 'default' value? Or would I clone a table for dynamic data and restore from a predefined source table if I want to restore values?

    Okay, I see saving happens to another file and the main DB viewable in the editor isn't updated. So there's two DB files, the one created at build as part of the distribution package, and another runtime copy with saved data, right?

    One last point, how do I check if a row/entity exists? eg.Cards table has 3 entries and I want to test if item number 5 exists.

    Code (CSharp):
    1.         DB_Cards.GetEntity(1).f_name = "splooky";
    2.         if (DB_Cards.GetEntity(5) != null) {
    3.             DB_Cards.GetEntity(5).f_amount = 999;
    4.         }
    This doesn't work!

    Of course testing a particular row number isn't useful, but I'd want to see if an ID already exists ahead of creating one. I guess it's a case of some Contains() test for an ID?
    Last edited: Oct 25, 2022
  2. BansheeGz


    Dec 17, 2016
    It means that if you:
    1) get database object (table/field/row) from database
    2) store it in some C# variable or field
    3) Load the data with SaveLoad add-on
    4) Trying to use variable/field from step #2 results in an error
    The reason why - is cause the whole database is reloaded

    SaveLoad add-on creates a temporary database in memory when Save method is called.
    It uses the default database (BGRepo.I) as a source of data and add-on merge settings as a guide which data needs to be saved and which data should be skipped.
    After that, it serializes temporary database to a byte array, destroy temporary database and return serialized byte array

    Code (CSharp):
    1. if (DB_Cards.CountEntities > 5)        
    Last edited: Oct 28, 2022
  3. tomraegan


    Mar 28, 2016

    I already own BGDatabase, but I've not used it much, nor do I know much about databases.

    I was wondering if you could advise me about whether or not BGDatase is the right plugin to use.

    I have 100 'enemies'. I need to make a record of up to 10 variables (ints, floats, strings and bools) each time players kill an enemy. I need to record each instance of a player killing an enemy, essentially appending the data to each field. A typical play session would involve 100 of the variables to be added to 100 times. It's important to understand that each time any variable is added to it is appended, not overwritten. There is no requirement that it be stored remotely.

    Upon level completion, and also from the Main Menu, a player can review this data in a chart. These charts need to reflect progress over time and draw from data hundreds (possibly thousands) of instances deep. There is no need for the charts to be relational or searchable.

    I guess what I'm asking is if keeping track of 1000 variables as they each accumulate data and keep adding ot the size of the recorded files is best done in BGDatabase? I don't need all the bells and whistles of a database, but it seems to do the best job of organising it.

    I also own Easy Save and am researching JSON, but I could use advice from a data expert.

    Last edited: Nov 14, 2022
  4. moroc


    Jan 20, 2014
    I added list<Vector3> as column and filled it with 10 000 values. After it BGRepo.Editor repaints for a long time with second breaks. I can't even get out of unity
  5. BansheeGz


    Dec 17, 2016

    If you have a lot of data, and you want to process it using complex queries/rules, using regular SQL database is a better solution.
    1) SQL database should have some parameters to limit memory usage. BGDatabase is in memory database, keeping all the data loaded
    2) SQL queries can have complex rules for result data calculations, which can result in better performance if proper indexes are created to avoid full scans. BGDatabase only has keys and single field indexes, which are limited compared to SQL queries optimizations

    Maybe even better, specialized solutions exist, I do not know
    Last edited: Nov 18, 2022
  6. BansheeGz


    Dec 17, 2016
    Could you, please, write to our support email, so I could send you an upgraded package with a fix?
    I can not DM you
    Or send me a message using "Start a conversation" button
  7. gekidoslair


    Sep 7, 2012
    having an issue adding a google sheets data source - I have the service setup in the google console, have entered my client id / secret etc but when I try to get tokens it fails with an error:


    [edit] - aha - had a stupid trailing space on one of the fields that was breaking the parsing apparently.
  8. BansheeGz


    Dec 17, 2016
    Thank you for the update, we will add a check for space characters inside parameters in the next release
  9. xinoHITO1


    Jul 2, 2012

    I'm using BGDatabase to store my prefabs and I'm trying to implement a tool to automate the way I add multiple prefabs into the database with an Editor Window. I can create a new row in my table and set the fields with primitive types (string, bool, int) but can't find a way to set asset type fields.

    I found some documentation on the website saying that I can import the Editor assembly to access a "SetAsset" function inside the BGField but it doesn't show up for me.

    Can anyone help me with this please?