Search Unity

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. moroc

    moroc

    Joined:
    Jan 20, 2014
    Posts:
    12
    It works. Excellent. Thank You.
     
  2. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Hello

    Somewhere along the line either due to an update or some change the "Hidden" fields are still showing up in runtime
    upload_2022-2-28_7-57-4.png

    How can I make sure they are not showing up?

    upload_2022-2-28_7-58-5.png

    Thank you

    Note; I am using latest plugins and BG from asset store
     
  3. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello,

    Could you please, confirm, I understood you correctly:
    1) In BGDatabase Window GUI, you have some fields, marked as hidden, and it works correctly
    1.png

    2) You use the "Runtime editor" plugin: https://www.bansheegz.com/BGDatabase/Downloads/RuntimeEditor/
    with "Settings mode" parameter equal to "Editor format" and "Settings File Path" parameter equal to your settings file location
    2.png

    3) When you enter play mode, runtime editor GUI shows hidden fields
    3.png


    Is it correct?
    If yes- could you please, make sure the "Settings File Path" parameter is indeed equal to the actual settings file location (as shown on image # 2)?
     
  4. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Correct,

    I normally use my custom one: Exel_Settings_KZ.json (its copied from my docs to StreamingAssets)
    https://pastebin.com/ra2W3abB

    Not sure why the fields still showing up in runtime, it wasn't in the past
     
  5. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    There are some hidden fields in the config:
    Code (CSharp):
    1. "HiddenFields": {
    2.           "values": [
    3.             "uVDB7TOJ/k+AvGIf0HuYMw",
    4.             "KasGh3vhb0anC7C8CPCfcQ",
    5.             "LO0p7LuDHkiiRXCiNH5YVw",
    6.             "OxKYxwtJ00Gsxc5SaL8Osg",
    7.             "vHJez2z6MUGqtnWa2rWLCA",
    8.             "ORoBplrqIkGd6Ilxmy8HXg"
    9.           ]
    10.         }
    The string encoded values are fields IDs
    And the table ID for these fields is
    Code (CSharp):
    1. H+U4DOwkF0mQQsSbCdopyQ
    Could you please, check if table ID and fields IDs are the same as your actual table ID and fields IDs?
    You can find table ID and field IDs under "Configuration" tab
    5.png

    Maybe you deleted the table or fields and then re-created them with the same names?
    In this case, the IDs will be different
    ID is assigned on table/field creation and never changes until table/field is deleted
     
    Last edited: Mar 1, 2022
  6. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    That's the weird thing, it is the same ones from what I can tell :p

    upload_2022-2-28_21-19-18.png
     
  7. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Could you, please, send me your database structure file?
    To create a database structure file, select Export/Import->DataSources and create a JSON data source, set Path to non-existent file and click on the Export button
    6.png
    The JSON file with database structure(tables/fields/addons) will be created, entities(rows) will not be included
    If you do not want to share your addons settings- delete the Addons section at the top of the file (especially if you use the LiveUpdate addon)
    7.png

    Please, send this file to us (using any channel you want) and we will try to reproduce the issue using the files you provided
    Thank you
     
  8. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Done thank you =) (pm'd)
     
  9. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Thanks again for the amazing support you guys always provide.

    if i make changes on runtime via script on BGEntity classes for some values, how do I save that spreadsheet so that if i open it from file explorer it has the same changes?
     
    BansheeGz likes this.
  10. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Another question,

    How can I Create a new spreadsheet via script and save it as with the fields created? I have a List<> that would like done in a spreadsheet
     
  11. Ultroman

    Ultroman

    Joined:
    Mar 10, 2014
    Posts:
    110
    Hello! I'm considering buying this for our company, to import existing Google Sheets of game data variables (prices and other such variables) into a database-like structure (which I see that this can do with classes).

    I have a few questions I cannot find the answer to in the documentation:
    1. Whether it can somehow ignore certain rows of a sheet tab, like if I use the _id column setup and I have e.g. a row of headers every 40 lines, can I then just leave the _id field blank or is there a certain "ignore tag" I can use? The documents have been set up by designers to give a good overview, but the values are still mostly in a database-like structure; it's just that there are some fluff-rows in certain places. (I see that Google Sheets doesn't include completely empty rows, so we'll make sure our fluff-rows have some value in some field; thanks for the note!).

    2. On the other axis, can I skip/ignore certain columns in certain sheet-tabs? Do I just leave the column name field blank to have them skipped?

    3. Will those ignored columns and rows persist in the Google Sheet if I export the data from the Unity editor to the Google Sheet, or does it replace the entire sheet structure? Either way, I guess the plan is to only make permanent changes via the Google Sheet and import from there; I don't think we'd ever be exporting from Unity to the Google Sheet.

    4. Can I choose which axis to use as rows and columns, so I can have a sheet that becomes a table with a single entity holding all the values in column 1, each keyed to their variable-name in column 0 (which acts like a header-row).

    5. Any way to generate a custom table using custom keys mapped to specific cells of a sheet, in order to handle something like this (see image), without resorting to a looong row of values, which isn't very neat for designers? In relation to question 4, it would be acceptable to have the axes flipped, so the values can at least extend downwards.
    upload_2022-3-9_18-57-4.png
     
    Last edited: Mar 10, 2022
  12. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello, sorry for a little delay :oops:
    The BGExcelImportGo script has Export() method, if you call it- all changes you made to database rows should be transferred to Excel file (if table/fields are included into Export settings).
    BGExcelImportGo component is the one holding all Excel parameters and export parameters are accessed via "Export settings" button (please, see the screenshot under the spoiler)
    25.png

    You can create a table dynamically in runtime, add required fields and rows.
    Here is example of creating new table "DynamicTable" with 2 fields: "intField" (int) and "floatField" (float) and 2 rows
    Code (CSharp):
    1. using BansheeGz.BGDatabase;
    2. using UnityEngine;
    3.  
    4. public class Test : MonoBehaviour
    5. {
    6.     /// <summary>
    7.     /// Example how to add new table dynamically in runtime
    8.     /// </summary>
    9.     private void Start()
    10.     {
    11.         //add new table
    12.         BGMetaEntity dynamicTable = new BGMetaRow(BGRepo.I, "DynamicTable");
    13.         //add intField(int) field
    14.         BGFieldInt intField = new BGFieldInt(dynamicTable, "intField");
    15.         //add floatField(float) field
    16.         BGFieldFloat floatField = new BGFieldFloat(dynamicTable, "floatField");
    17.        
    18.         //first row
    19.         BGEntity firstRow = dynamicTable.NewEntity();
    20.         firstRow.Name = "First row";
    21.         intField[firstRow.Index] = 1;
    22.         floatField[firstRow.Index] = 1.1f;
    23.  
    24.         //second row
    25.         BGEntity secondRow = dynamicTable.NewEntity();
    26.         secondRow.Name = "Second row";
    27.         intField[secondRow.Index] = 2;
    28.         floatField[secondRow.Index] = 2.2f;
    29.     }
    30. }
    27.png


    Then you need to ensure that this new table is included into export settings.
    There are 2 options available to include created table into export settings:
    1) The first option is to include all tables/fields.
    This is the easiest method and it does not require any additional steps- but it also means that all table/fields will be exported
    Just toggle on all three top level toggles ("Add missing"/"Remove orphaned"/"Update matching") and all tables and fields will be automatically added to the export (including the ones, added dynamically in runtime)
    26.png
    2) The second option- is to modify export settings in runtime
    Here is an example how to include table "Test" with all fields into export.
    If you need to selectively include only some fields into the export- please, let me know
    Code (CSharp):
    1. using BansheeGz.BGDatabase;
    2. using UnityEngine;
    3.  
    4. public class Test : MonoBehaviour
    5. {
    6.     //reference to excel manager
    7.     public BGExcelImportGo excelManager;
    8.     /// <summary>
    9.     /// Example how to add "Test" table with all fields into export settings
    10.     /// </summary>
    11.     private void Start()
    12.     {
    13.         //database table
    14.         BGMetaEntity table = BGRepo.I["Test"];
    15.         //export settings
    16.         BGMergeSettingsEntity exportSettings = excelManager.ExportSettings;
    17.  
    18.         // add new table to export settings
    19.         BGMergeSettingsEntity.MetaSettings testTableSettings = exportSettings.Ensure(table.Id);
    20.         //toggle on three parameters
    21.         testTableSettings.AddMissing = testTableSettings.RemoveOrphaned = testTableSettings.UpdateMatching = true;
    22.        
    23.         //uncomment this line to export the data
    24.         // excelManager.Export();
    25.     }
    26. }
    If you have any issues implementing this concept- please, let me know- I could send you an example project
     
    zKici likes this.
  13. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello,
    1) Currently the only supported data layout format is the following:
    1.1) The first row contains the field names
    1.2) Rows, starting with the 2nd one, contain field values
    2) Empty rows (rows without any value under valid fields columns) will be ignored
    3) We could add some special tag, which could be used to skip rows even if some values are present
    4) Also, there are some settings, which can be used for ignoring certain rows.
    For example if you toggle off "add missing" and "remove orphaned" toggles- all rows without valid _id value will be ignored during import or export

    If the column name is empty or can not be mapped to a database field- the whole column will be ignored

    1) The structure will be preserved
    2) Even if you export data from Unity Editor to GoogleSheets- the ignored columns and rows should not be overwritten
    Before writing values to GoogleSheet, export procedure determines the target cells and skips the ignored ones

    I think we could add support for such layout, but it's hard to estimate how much time it can take

    No, such feature is not currently supported unfortunately

    If you are interested in evaluating our asset- please, send me a message using forum conversations or using our support email
     
    Last edited: Mar 12, 2022
    Ultroman likes this.
  14. Ultroman

    Ultroman

    Joined:
    Mar 10, 2014
    Posts:
    110
    Thank you very much for your response! That information all helps a lot, actually.

    I'm happy to say, that I already took the plunge and got 2 seats for us, and the asset is great! It's only Google's identification and credential service spiderweb that's a hurdle when starting to use this asset, and your guides are mostly up-to-date with the steps needed, so thank you for those <3

    One more thing, then: I've added a column on the far left of my Google Sheet, with a header named _id. When I import the structure of my sheet, it asks to include the _id field (but remove the underscore from the field name).
    Should I:
    1. include it in the structure
    2. ignore it, and it'll be filled into the sheet when I export data to it after importing data from it?

    I guess the question is, do I have to manually link the _id field in my structure, or is it linked "automagically"? When/how do the ids get into my empty _id column in the sheet? The instructions just say to make sure the field is in the sheet. It doesn't say whether it has to be all the way on the left or how to link it. At least not for Google Sheets.

    EDIT: I tried omitting (ignore) the _id field on import, and then pressed Export to see if it would push the generated ids from the Id-column of the Meta to the _id column in the Google Sheet, and then I get this error:
    "Unable to parse range: <insert Meta name>!A0:A0
    2022-03-15 15_05_36-Window.png
    ...which I can't make sense of, unless A0 means row 1, which I'm pretty sure it doesn't?

    This is the test document structure. Only the yellow ones will be included in the Meta, but what about that _id field?
    upload_2022-3-15_15-13-59.png
     
    Last edited: Mar 23, 2022
    BansheeGz likes this.
  15. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello, thank you for buying our asset!
    I agree, that Google authentication is very confusing (especially OAuth 2.0), I hope there is a good reason behind this

    You did the right thing by adding _id column
    _id column should not come up in data extraction wizard cause it's a system field, it's a mistake we did, sorry
    Disabling _id column should fix the error or alternatively use the attached package with a fix (_id column will be skipped)
    Please, use "Data extraction wizard" to extract database structure (tables/fields) only, do not transfer rows with it
    33.png
    Once the database structure is created
    34.png
    Use an "export/import job" to transfer data.
    Make sure to toggle on "update IDs on import" and include table(s) you want to transfer data for(they will be highlighted in green)
    35.png
    After clicking on "Import" button, the rows should be transferred to the database, and GoogleSheets _id should be filled with the same values database has
    36.png
    These IDs will be used to identify- to which database row Google sheet row is mapped

    If you encounter any error during importing data- please, let me know and we will investigate this issue
     

    Attached Files:

    Ultroman likes this.
  16. Ultroman

    Ultroman

    Joined:
    Mar 10, 2014
    Posts:
    110
    This is all working perfectly! Absolutely stellar asset you guys have made!
     
    BansheeGz likes this.
  17. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    239
    I forget if I asked this before- but is it possible to open multiple repo files at the same time.
     
  18. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    No, it's not possible unfortunately
    You can open two database files using Merge tool and see the difference : https://www.bansheegz.com/BGDatabase/MergeTool/
     
  19. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    326
    on install
    Code (CSharp):
    1. Unable to update following assemblies:Assets/BansheeGz/BGDatabase/Editor/Scripts/BGDatabaseEditor.dll (Name = BGDatabaseEditor, Error = -2147450735) (Output: C:\Users\S\AppData\Local\Temp\tmp54d6b453.tmp)
    2.  
    3. Could not execute because the application was not found or a compatible .NET SDK is not installed.
    4. Possible reasons for this include:
    5.   * You intended to execute a .NET program:
    6.       The application 'C:/Program' does not exist.
    7.   * You intended to execute a .NET SDK command:
    8.       It was not possible to find any installed .NET SDKs.
    9.       Install a .NET SDK from:
    10.         https://aka.ms/dotnet-download
    11. Assets/BansheeGz/BGDatabase/Scripts/BGDatabase.dll (Name = BGDatabase, Error = -2147450735) (Output: C:\Users\S\AppData\Local\Temp\tmp305da941.tmp)
    12.  
    13. Could not execute because the application was not found or a compatible .NET SDK is not installed.
    14. Possible reasons for this include:
    15.   * You intended to execute a .NET program:
    16.       The application 'C:/Program' does not exist.
    17.   * You intended to execute a .NET SDK command:
    18.       It was not possible to find any installed .NET SDKs.
    19.       Install a .NET SDK from:
    20.         https://aka.ms/dotnet-download
    21.  
    22. UnityEditor.Scripting.APIUpdaterLogger:WriteErrorToConsole (string,object[])
    23. UnityEditorInternal.APIUpdating.APIUpdaterManager:HandleAssemblyUpdaterErrors (System.Collections.Generic.IList`1<UnityEditorInternal.APIUpdating.AssemblyUpdaterUpdateTask>)
    24. UnityEditorInternal.APIUpdating.APIUpdaterManager:UpdateAssemblies ()
    Could not execute because the application was not found or a compatible .NET SDK is not installed.
    Possible reasons for this include:
     
  20. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    You use Unity 2022 beta, correct?
    I think it is some issue with Unity API updater https://docs.unity3d.com/Manual/APIUpdater.html , which can not run on your computer properly for some reason
    I DMed you a already upgraded package (upgraded with Unity 2022.1.0b14)- it should work properly without Unity API updater
     
  21. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    326
    Thanks (2022.1.0b14) yeah it works now
     
  22. gamejzb

    gamejzb

    Joined:
    Oct 29, 2014
    Posts:
    8
    upload_2022-6-29_10-22-57.png Our project update to v1.7.7. This error appear when open BG Database windows.We canot open old data any more.

    BGException: Can not deserialize field ItemAttributeInfo.AttrType: enum type ChiefOfImmortal.Definition.Enum.AttributeType has wrong underlying type, expected System.Int32 found System.Byte !
     
  23. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Find your AttributeType enum definition in C# source file and remove
    : byte
    snippet
    This should fix the error
    78.png

    "underlying type" refers to the type your enum is extended from.
    There are 3 options- int (default type), short and byte
    This error message "enum type ChiefOfImmortal.Definition.Enum.AttributeType has wrong underlying type, expected System.Int32 found System.Byte" means, that AttributeType enum was originally extended from int type, but later this type was changed to byte
     
  24. gamejzb

    gamejzb

    Joined:
    Oct 29, 2014
    Posts:
    8
    Ok, got it.Thanks
    By the way, we canont use enumbyte any more?In pre version,our project use many enumbyte,because we thought it will reduce the data persistence file size by using enumbyte.
     
  25. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    enumByte and enumShort fields are still available

    1) For new fields, select appropriate enum field type in "Add field to [MetaName]" dialog
    79.png

    2) If you want to migrate existing enum field to new enum type without losing existing data- please follow the guide below.
    The guide is written for enum->enumByte migration and it can also be used for other types as well

    The guide for changing enum underlying type starts here:
    2.1) Backup your database just in case
    2.2) Locate your enum in C# source files and create a copy with target enum type (in our case it's byte).
    Change a copy's name by appending "Temp" postfix
    80.png

    2.3) Locate your enum field under "Configuration" tab and open "Change field type" dialog
    81.png

    2.4) Select enumByte as a new field type and set enum type name to your temp copy enum.
    Click on "Change field type" button and save database.
    82.png

    2.5) Switch back to your C# source file and change your enum underlying type to the target type (in our case it's byte type)
    83.png

    The guide is continuted in the next message.....
     
    Last edited: Jun 29, 2022
  26. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    ...The guide (2nd part)

    2.6) Switch back to the database window and change enum type from your temp enum copy (AttributeTypeTemp) to the actual type (AttributeType).
    Save database
    84.png

    2.7) Switch to you C# source file and delete temp enum
    85.png
    The end of the guide
     
    Last edited: Jun 29, 2022
  27. gamejzb

    gamejzb

    Joined:
    Oct 29, 2014
    Posts:
    8
    Thanks. it's migrate well follow your guide step
     
  28. gamejzb

    gamejzb

    Joined:
    Oct 29, 2014
    Posts:
    8
  29. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
  30. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    How can I get out of ForEachEntity, I'd like to use return; or continue; or break; if possible

    Thank you
     
  31. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Use for loop to iterate rows instead of ForEachEntity method (I assume MyTable is the name of CodeGenerator addon's generated C# class)
    Code (CSharp):
    1.         int count = MyTable.CountEntities;
    2.         for (int i = 0; i < count; i++)
    3.         {
    4.             MyTable entity = MyTable.GetEntity(i);
    5.             //some code
    6.             if (condition) break;
    7.         }
     
    zKici likes this.
  32. LuiBroDood

    LuiBroDood

    Joined:
    Mar 13, 2019
    Posts:
    84
    it would be nice if i could like, ctrl + click ... or shift + click .. or something on a relation field
    and it will bring me to the relation in the database

    as it is i gotta see the name and look it up right?
    is there a way to go to it quick?

    thanks
     
  33. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Do you mean to click on the cell's button to quickly navigate to the related row?
    23.png
     
    Last edited: Aug 13, 2022
  34. LuiBroDood

    LuiBroDood

    Joined:
    Mar 13, 2019
    Posts:
    84
    yes that would be great! and make it work with multiple relations too
    click to edit , right click to goto ... or opposite .. or ctrl + click .. shift + click .. whichever you think is best
     
  35. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    I will send you an updated package as soon as it's ready in a private message, thank you for your suggestion!
     
  36. Tropobor

    Tropobor

    Joined:
    Mar 24, 2014
    Posts:
    73
    Hi, Is it possible to have my own set of organised data in _id column and then import it in BG ?
     
  37. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hi,

    1) You can generate valid ID value using this C# code:
    Code (CSharp):
    1. var id = Convert.ToBase64String(Guid.NewGuid().ToByteArray()).Substring(0, 22);
    2) If you want to use GoogleSheets, you also need to prepend ID value with apostrophe ' if ID value starts with a plus symbol +, for example if ID value is +QFgWESPnkmT/ebcpL3JMQ the GoogleSheet cell value should be '+QFgWESPnkmT/ebcpL3JMQ
    Code (CSharp):
    1. if (id[0] == '+') id = '\'' + id;
    3) Alternatively, you can leave _id values empty and toggle "Update IDs on import" checkbox on. In this case IDs will be filled in on import
    40.png
     
    Tropobor likes this.
  38. gamejzb

    gamejzb

    Joined:
    Oct 29, 2014
    Posts:
    8
    HI,
    I want clear all game data when return game main menu. but game crash every time do this. My clear data C# code
    Code (CSharp):
    1.  
    2. // BGRepo.I.Clear() comment or no comment is same issue occur!!!
    3. BGRepo.I.Clear();
    4. BGRepo.Load();
    5.  
    crash info:
    Code (CSharp):
    1.  
    2. System.Exception: Index is out of bounds, greater or equal to maxIndex, 0>=0
    3.   at BansheeGz.BGDatabase.BGStoreField`1[T].get_Item (System.Int32 index) [0x00067] in <3987bc3219b44ed6b6b19d17a55df6ca>:0
    4.   at BansheeGz.BGDatabase.BGFieldCachedA`1[T].get_Item (System.Int32 entityIndex) [0x00000] in <3987bc3219b44ed6b6b19d17a55df6ca>:0
    5.   at BansheeGz.BGDatabase.BGIndexStorage`1[T].GetKey (System.Int32 entityIndex) [0x00000] in <3987bc3219b44ed6b6b19d17a55df6ca>:0
    6.   at BansheeGz.BGDatabase.BGIndexStorage`1[T].EntityAddedListener (System.Object sender, BansheeGz.BGDatabase.BGEventArgsAnyEntity e) [0x00017] in <3987bc3219b44ed6b6b19d17a55df6ca>:0
    7.   at BansheeGz.BGDatabase.BGMetaEntity.FireEntityAdded (BansheeGz.BGDatabase.BGEntity entity) [0x00027] in <3987bc3219b44ed6b6b19d17a55df6ca>:0
    8.   at BansheeGz.BGDatabase.BGMetaEntity.NewEntity () [0x0002b] in <3987bc3219b44ed6b6b19d17a55df6ca>:0
    9.   at ChiefOfImmortal.RunData.DataBase.HexRegionInfo.NewEntity () [0x00000] in J:\newcode\xgame\ChiefOfImmortalClient\Assets\Main\Scripts\RunData\Generated\BGGeneratedExtensionClasses.cs:11392
    10.   at ChiefOfImmortal.UI.FormNewGameSetting.OnOpen (System.Object userData) [0x00043] in J:\newcode\xgame\ChiefOfImmortalClient\Assets\Main\Scripts\UI\FormNewGameSetting.cs:64
    11.  
    12.  
    This issue has tormented me for days.I have to check mass logic code. Simplified my table to this:
    upload_2022-9-12_17-58-12.png
    Finally i find the issue how to reproduced simply (note:My project use CodeGen addon):
    1)after databe load, call the GetEntityByKeyXXX or FindEntitiesByIndexIndexXXX.
    2) clear the databese or load the default database.
    3) call the newentity
    4) Crash.
    example code:
    Code (CSharp):
    1.  // BGRepo.I.Clear() comment or no, same issue occur!!!
    2.             BGRepo.I.Clear();
    3.             BGRepo.Load();
    4.          
    5.             m_CurSectPresetInfo = null;
    6.             m_RunSetting = DatabaseHelper.RunSetting;
    7.             m_RunSetting.InitRoleAvatarData = DataCenterAvatar.Instance.CreateARandomCfg(Sex.Man);
    8.            
    9.             //first call success,  second call crash !!
    10.              var re = HexRegionInfo.NewEntity();
    11.            
    12.              //comment follow 2 row code will no issue. once one of two rows called, second call HexRegionInfo.NewEntity() crash.
    13.              var test1 = HexRegionInfo.GetEntityByKeyEntiyID(Random.Range(0,19999));
    14.              var test2 = HexRegionInfo.FindEntitiesByIndexIndexSelf(new BGIndexOperatorBetween<int>(0,20,false,false));
    So I guess maybe our code about clear databe is wrong? or we cannot use the key or index function?
    If our code is wrong, cCan u post a safe code about clear database ? Thanks
     
  39. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hi, thank you for reporting this problem!
    I've sent you an updated package via email, hopefully the issue was fixed, sorry for the inconvenience
    If something does not work as expected - please, let me know
     
  40. gamejzb

    gamejzb

    Joined:
    Oct 29, 2014
    Posts:
    8
    Hi,
    I have test the preview package in my game.the issue has been fixed.
    Thanks.
     
    BansheeGz likes this.
  41. mkhoata

    mkhoata

    Joined:
    Feb 11, 2022
    Posts:
    3
    Hi, when we use LiveUpdate feature for Google Sheet, is there a way to find out when the sheet just got updated?
    I'm looking for an event callback or something like that, but I can't find one in the documentation. I think I'm missing it.
    Thank you.
     
  42. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hi,
    Sorry, this feature is not available
    Google Sheets API does not support it as well
    Probably it can be implemented with Google Drive API files.get method https://developers.google.com/drive/api/v3/reference/files/get , which optionally returns modification time
    You can call this method directly from the clients, but probably it's better to use a proxy web server, because of these reasons:
    1) No need to expose Google Drive API key (authentication token)
    2) No chance to exceed Google Drive API quotas https://developers.google.com/drive/api/guides/limits
    3) Web server can query Google Drive API periodically and once the change is detected it can notify all the clients using server-sent events (SSE) https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events

    Maybe some other options are available, for example web server can be replaced with Google apps script web application https://developers.google.com/apps-script/guides/web , but I'm not sure if it supports SSE or similar technique
     
  43. mkhoata

    mkhoata

    Joined:
    Feb 11, 2022
    Posts:
    3
    Oh I got it.
    Thank you very much for pointing this out.
    The current features are so much useful though.
    I'm thinking of using a checksum integer field. Whenever i change any data on Google Sheet, I also increase this checksum. Then on the client, I will check if the checksum has changed at some early point when app launches (that I'm sure the sheet just got downloaded).
    I hope someone will find this abnormal method useful :D
     
    BansheeGz likes this.
  44. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Hello @BansheeGz ,

    Does BG Database works on every platforms, like : iOS and Android devices, PC, Xbox series X and S, PS 5 etc. ?
    How is memory managed ? Is it possible to choose when the DB is loaded ? Is it possible to load only needed tables ?

    Thanks
     
  45. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello,

    Database was tested on Desktop (Windows/Mac), Mobile(IOS/Android) and WEBGl (it works with some minor restrictions)
    Unfortunately, I can not tell anything about consoles (XBox/Playstation/Nintendo Switch), cause we never had a chance to test it on these platforms
    By default the whole database is loaded into memory
    Fields data is stored in arrays
    Database is loaded on demand- when it's accessed for the first time
    There is a partitioning add-on ( https://www.bansheegz.com/BGDatabase/Addons/Partition/ ), which allows to split database data into several files on the row level.
    Each row can have a "partition" field, pointing to a partition.
    Each partition is stored in it's own file, which is not loaded automatically, you can load/unload partitions manually in runtime.
    Unfortunately, some restrictions apply ( https://www.bansheegz.com/BGDatabase/Addons/Partition/#limitations , "Restrictions" section at the bottom of the page ),and the main restriction, I think, is that it works well only for readonly data, cause when you unload the partition- partition's data is deleted and when you load it again- the default values are loaded
     
  46. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    326
    "WEBGl (it works with some minor restrictions)" ...what kind of restrictions?
     
  47. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    Hi. Bought this to replace my much-loved GameData Editor which is no longer supported. I'm wanting runtime database access, read and write, which this should provide. Great. I'm struggling a bit to get my head around BGDatabase. I want to define my database in Excel and just import it. I found this document as part of the import package, which should be linked from the main documentation as I had trouble finding it again (hooray for Browser History!)

    https://www.bansheegz.com/BGDatabase/Downloads/EditorExcel/guide_import.html

    I have got to the point I can import a database with fields. Is it possible to specify the field type within Excel? GDEditor used a row under field name to specify datatype which was super convenient. In particular, I want a field to refer to another table. eg. an Upgrades table could have items with a field Weapon that points to an item in the Weapons field. Is that possible to manage in the Excel database, or do I have to create my schema in the Editor?

    Also will it always be necessary to close Excel to import data? GDEditor could run in parallel and I could readily update. I guess that's what the Excel sync plugin is for?

    Edit: discovered it myself exporting a database with relational fields. I can populate one field with table name and _id. Sadly this isn't intuitive for use in Excel.

    Would it be possible to update the import system so a DB layout like this would work?

    upload_2022-10-24_11-26-42.png

    The rows and columns marked 'ignore' are there to make the table easier for the user and were ignored by the database tool. The important part here is the field type specification. The "challenge" column specifies a reference by name to the Challenges table. This makes it a doddle to have human-readable referential fields. Without this referencing tables by item name, spreadsheet import seems pretty limited in value.
     
    Last edited: Oct 24, 2022
  48. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Here is the full list of restrictions for WebGL platform we encountered so far:

    1) StreamingAssets database loader does not work (Resources and Custom loaders work fine) https://www.bansheegz.com/BGDatabase/Setup/#loaders

    2) Addressables synchronous workflow (loading assets synchronously) introduced in Addressables 1.17.17 does not work, so asynchronous methods should be used. Here is a link to Unity docs: https://docs.unity3d.com/Packages/com.unity.addressables@1.20/manual/SynchronousAddressables.html , the warning about WebGL is at the bottom of the page

    3) LiveUpdate plugin requires special asynchronous setup https://www.bansheegz.com/BGDatabase/Addons/LiveUpdate/#webgl . Also, Cross-Origin requests should be allowed on the hosting web server.

    4) SaveLoad Playmaker actions require special setup https://www.bansheegz.com/BGDatabase/Downloads/RuntimeSaveLoadPlaymaker/#webGl , cause WebGL does not have access to local file system. I should also mention, that we do not recommend saving database content as the only game session information, but rather use a specialized tool for saving/loading and store database data as only a part of saved information, as a binary array along with other saved data for more flexibility.
     
  49. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    we've just added "back" buttons to our web guides, sorry about it

    No, it's not currently possible
    1) Our import jobs does not affect database structure (tables/fields), only rows (entities)
    2) For importing database structure currently we have a dedicated wizard tool, which reads all sheets/header rows and creates corresponding tables/fields in the database.
    Field type is inferred based on the Excel data and 4 main data types (boolean, int, float, string) and you can change it in the process
    63.png
    There are also options to skip/ignore sheets/columns ("ignore" column and "IgnoredSheet" sheet on the screenshot above) and option to save configuration in the data source settings if you toggle on "Save name mapping to data source" toggle at the first wizard step and save database settings after wizard is complete (using "Save all" or "Save settings" toolbar buttons)
    65.png

    "Disabled config" only affects data structure wizard- if you run it several times, all ignored sheets/columns will be saved between sessions. You can also add ignored tables/fields manually
    66.png

    Jobs automatically ignore sheets/columns if no proper mapping to a table/field is found. If you run import job and after that open "Log" tab- ignored sheets and columns will be highlighted in red color along with other errors
    64.png

    Database structure is managed inside Editor only
    You can use "Data structure wizard" I described above to quickly transfer new tables/fields from Excel or GoogleSheets to the database

    It's possible to run an import job with Excel file opened in the Excel editor if "Update IDs on import" toggle is off.
    68.png
    The comment will be continued in the next post...
     
    Last edited: Oct 25, 2022
  50. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    By default, we use IDs to identify the row and keep the link between Excel row and database row.
    Also, IDs are used internally to reference a row (data binders, graph tool, MonoBehaviour generated classes, referential fields - all use IDs to reference rows)

    Rows with empty IDs in Excel (_id column) are considered to be new rows
    Once you have new rows in Excel - you can run an import job with "Update IDs on import" toggle on
    The rows will be added to the database and database IDs will be transferred back to Excel file, thus creating a link between database row and Excel sheet's row
    70.png
    Transferring IDs to the Excel file requires write access - so the Excel file should be closed in this case.
    You can create 2 different jobs with different settings-
    1) for adding new rows with "Update IDs on import" toggle on and "Add new rows" setting on
    2) another one for updating matching rows with "Update IDs on import" toggle off and "Add new rows" setting off
    78.png

    Alternatively, there are also options to use other fields as ID instead of regular IDs
    77.png
    You need to ensure that each row has a unique value for ID field and if you change this value either in Excel file or in the database without changing the corresponding value on the opposite side - the link between database row and Excel row will be broken
    It's ID or RowName_ID, RowName_ part is optional, and it's ignored on import, only ID part is used
    RowName_ part is added for readability only

    Can "Data structure wizard", I described above, be used instead of this extra markup?
    It supports ignoring tables/fields and selecting field types

    We can try to add an option for referencing rows with row's name instead of ID for referential fields
    We are not sure yet what side effects it can have.
    For example, round-trip conversion can not be guaranteed - there could be a situation, when you export data to Excel, then import it back and data for referential fields is changed as a result
    For example, referencing a row with empty name is possible in database, but not in Excel (relation is lost) or referencing different rows with the same name - all rows will be pointing to the single row
     
    Last edited: Oct 25, 2022