Instead of PlayerPrefs, we decided to use SQLite for this purpose. SQLite is a lightweight, embeddable, and highly reliable SQL database engine that works incredibly well for mobile devices. However, embedding SQLite in Unity is not straightforward. The Implementation Getting started.Net and Unity do not support SQLite out of the box. Unity plugins are available for select Play Core APIs, including Play Asset Delivery. Download the latest release from Google Play Plugins for Unity releases. This is a single package that includes Play Core plugins as well as other Play plugins, such as Play In-app Billing and Play Instant.
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers. Create new folder under Assets Folder Rename it Plugins. Copy sqlite3.def and sqlite3.dll into Assets/Plugins in your unity project.You can download these files here for windows (Precompiled Binaries for Windows). C# unity sqlite local database I am making a small game in Unity and I'm in need of a database. I tried using SQlite database because that seemed to be recommended by the internet. Now i'm having troubles with actually connecting to the local database via c#.
I am making a small game in Unity and I'm in need of a database. I tried using SQlite database because that seemed to be recommended by the internet.
Now i'm having troubles with actually connecting to the local database via c#.
I implemented the Data en SQLite .dll's. I am trying to get 1 name from the database that I created using SQLite developer.
Below is my DataConnection class, which I use to connect to the database.
Then I call the following method from another class:
I get the following errors when running the code:
So I'm guessing it has something to do with a 32/64 -bit mismatch or is there something wrong with creating an instance of a script like this?:
Happy to receive any help at all. I'm familier with using database, just new to SQLite.
by: Alexandre Aragão
Project Information
A simple unity project that aims to test SQLite3 in unity-compatible platforms. This project was developed in Unity 2019.3.10f.
Usage
Well, there is no real usage of this project. But it is useful for check platforms support of SQLite3. For use, just clone the project and open it with unity.
The application tests:
- SQLite Connection String
- SQLite Connection (and database file check)
- SQLite CREATE TABLE command
- SQLite INSERT INTO command
- SQLite UPDATE command
- SQLite DELETE command
- SQLite DROP TABLE command
Useful information
This project don’t use any plugin but SQLite3. Which means that Plugins folder only contains plugins for SQLite3, so you can copy the folder and paste it in any other project. Easy SQLite3.
Interface explanation
The application has one main screen, that shows some system information and some SQLite functions.
Figure 1. Application scene at first moment (Linux).
When runnig the application you probaly won’t see the screen as show Figure 1. Once the application starts, it will shows all colected data and informations. Then you will probaly see the screen as show Figure 2.
Figure 2. Application scene after data loading (Linux).
Of course, you can get an error, as shows Figure 3b.
Figure 3b. SQLite fail (Android).
States explanation
- waiting - The application is waiting for data
- success - The command was successfully executed
- fail - An error occurred while executing the command
- aborted - An error occurred before this command was executed
Tests
Target test platforms
Unity Sqlite Tutorial
Unity Sqlite3
If you has tested some of the unchecked options, let me know 😃
Tests results
Platform | Application works? | SQLite3 works? | Errors |
---|---|---|---|
Linux UnityEditor | Yes | Yes | None |
Linux UnityPlayer | Yes | Yes | None |
Android | Yes | Yes | None |
IPhone | None | ||
Windows UnityEditor | Yes | Yes | None |
Windows UnityPlayer | Yes | Yes | None |
MacOS UnityEditor | None | ||
MacOS UnityPlayer | None | ||
WebGL | None | ||
XBOX 360 | None | ||
XBOX ONE | None | ||
PS3 | None | ||
PS4 | None |
Icons licenses
- Android and Xbox One icons made by Pixel perfect from www.flaticon.com
- Web icon made by bqlqn from www.flaticon.com
- Linux, Windows, MacOS and PS4 icons made by Freepik from www.flaticon.com
- Default OS icon made by Eucalyp from www.flaticon.com