.
PlayerPrefs를 사용해서 프로그램을 구현하고 있었는데 저장해야 할 데이터가 많아지고 복잡해져서, 알아보기 쉽게 사용하고자 하는 목적으로 결국 데이터베이스를 구현하게 되었다. SQLite를 사용한 이유는 네트워크 없이 게임을 할 수 있게 하고 싶기 때문이다. 이 글에는 unity와 sqlite를 연동하는 과정을 간단하게 기록하였다.
.
unity 버전: 2019.3.10f1
설치에 대한 대부분의 과정은 아래 두 블로그를 참고하였다.
유니티와 sqlite 연동하기 C#(다운, 사용법, PC, android, DB, query)
제가 sqlite를 진행하면서 겪었던 사항들이 많아서 다른 분도 저처럼 고생 안 했으면 좋겠다는 생각에 sqlite 연동 법을 쓰게 됐습니다. 다운로드부터 쿼리 던지는것까지 해보도록 하겠습니다. (네
mungto.tistory.com
내가 사용하는 버전의 경우, System.Data.dll 은 아래 경로에 있었다.
( C:\Program Files\Unity\Hub\Editor\2019.3.10f1\Editor\Data\MonoBleedingEdge\lib\mono\unityjit )
이 부분은 유니티 포럼을 참고하였다.
Can't load System.Data.dll
Hello, I'm pretty new to Unity but starting to understand how it works. I've downloaded the last Unity (2018.1) and changed the scripting runtime...
forum.unity.com
세팅 후 오류가 발생했다.
로그는 Loading assembly failed 'Assets/Plugins/System.data.dll로,
[Solution] Loading assembly failed Assets/Plugins/System.data.dll'
Development Environments OS : Windows 10 Unity Version : 2019 2.3f1 Visual studio 2019 Community (Solution) Loading Assembly fail Error Loading assembly failed 'Assets/Plugins/System.data.dll'..
devkoboso.com
위 블로그를 참고해서 Mono.Data.Sqlite를 다운받자 해결되었다.
.
예제 실행
devkoboso.com/entry/Unity-2019-23f1-Sqlite-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0-1
Unity 2019 2.3f1 Sqlite 사용하기 -1
0. SQLite Install https://www.sqlite.org/download.html Windows 에서 개발하고있으므로. 이것을 설치했음. 필요 환경에따라 맞추어 설치하면 된다. 2개의 파일을 Assets/Plugins Import 해준다. 1. DB Brows..
devkoboso.com
위 블로그에 있는 예제를 실행해보았다.
no such table Exception이 떴는데, 아래 포럼을 참고해서 경로를 바꾸자 정상적으로 실행되었다.
바꾼 코드는 아래와 같으며, /StreamingAssets/를 추가해줬다.
string conn = "URI=file:" + Application.dataPath + "/StreamingAssets/test.db";
answers.unity.com/questions/513862/sqlite-no-such-table.html
SQLite: no such table - Unity Answers
answers.unity.com
DB 연결이 성공적으로 되고, 데이터를 읽어올 수 있다.
.
'unity' 카테고리의 다른 글
[201106] 유니티 간단한 애니메이션 만들기 (0) | 2020.11.06 |
---|