Search Unity

Question issue using SQliter asset, help needed

Discussion in 'Scripting' started by enzoravo, Sep 5, 2021.

  1. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    hello, i'm making a game using SQliter to use the sqlite database to save all player data.

    it's working as expected in editor, bue when i build the game and test it in another computer or in the same computer but in another drive/folder that is not part of the unity project the game is not working.

    i checked the runtime log to see what is the problem and i found this:

    Code (CSharp):
    1. Fallback handler could not load library I:/ReleaseBuild/SokoTrap_Data/Mono/sqlite
    2. Fallback handler could not load library I:/ReleaseBuild/SokoTrap_Data/Mono/sqlite.dll
    3. Fallback handler could not load library I:/ReleaseBuild/SokoTrap_Data/Mono/sqlite
    4. Fallback handler could not load library I:/ReleaseBuild/SokoTrap_Data/Mono/libsqlite
    5. Fallback handler could not load library I:/ReleaseBuild/SokoTrap_Data/Mono/libsqlite.dll
    i checked the dll in the plugin folder and is named sqlite3.dll, i tried changing the name to sqlite.dll and after that i receive the next error:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2.   at persistGameSlot.getPlayerCurrentMapNameLevel () [0x00017] in <3a40d1d790794996ba2f5ac935cb4a1a>:0
    3.   at Sokoban_GameManager.SetupMap () [0x00024] in <3a40d1d790794996ba2f5ac935cb4a1a>:0
    4.   at Sokoban_GameManager.Start () [0x00021] in <3a40d1d790794996ba2f5ac935cb4a1a>:0
    5.  
    i know this code mean that i have a null reference, but the null one is an object that must be filled with data returned from the database.

    don't know what is happening, tried to put the dll in the root folder of the game and also in the data folder in Mono folder as the log file said, same result with both options, not working.

    any idea what i need to do to fix this issue ?

    thanks in advance for all the help.
     
  2. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    sorry for the bump, but i need help with this issue
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    What is SQliter? What asset did you download?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
  5. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Did you get the Example.unity sample scene working? That asset is over 5 years old with the most recent Unity version 5.4.2, and the support site no longer seems to exist.
     
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    Just noticed this line above ^ ^ ^... I'm not really sure saving it in a database is going to earn you anything but constantly-appearing future integration headaches precisely like what you are seeing now.

    Generally just serialize your save data, write it to disk as a file. Here's some more notes:

    Load/Save steps:

    https://forum.unity.com/threads/save-system-questions.930366/#post-6087384

    Don't use the binary formatter/serializer: it is insecure, it cannot be made secure, and it makes debugging very difficult, plus it actually will NOT prevent people from modifying your save data on their computers.

    https://docs.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide

    When loading, you can never re-create a MonoBehaviour or ScriptableObject instance directly from JSON. The reason is they are hybrid C# and native engine objects, and when the JSON package calls
    new
    to make one, it cannot make the native engine portion of the object.

    Instead you must first create the MonoBehaviour using AddComponent<T>() on a GameObject instance, or use ScriptableObject.CreateInstance<T>() to make your SO, then use the appropriate JSON "populate object" call to fill in its public fields.
     
    enzoravo likes this.
  8. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    yes, the sample scene is working, also my game is working too, the problem is when i build the game and try to run it as standalone; but i will try use the one that @Kurt-Dekker told me to use.
     
    JeffDUnity3D likes this.
  9. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    thanks for the help @Kurt-Dekker, i removed the old SQliter and used this one and is working like a charm, tested on my dev pc, running it in another hard disk and also in my test pc (the one without unity3d editor installed).

    thanks again for the help
     
    Kurt-Dekker likes this.