Giter Club home page Giter Club logo

slugdb's Introduction

SlugDB

The SlugDB is a database solution for Unity, you'll need Odin to use it. SlugDB's goal is to combine Unity's powerfull editor scripting with a traditional database approach (think MySQL). It will allow you to make typesafe queuries. Most of the heavy lifting in terms of editor scripting will be left to Odin and will allow us to edit json text files in the Unity.

Core concepts

The database is made of tables, tables contains rows (just like MySQL). For example you have a Person table and it is made of all your favourite characters (rows).

Creating a table

To Create a table, create a class that inherits from Row (I recognize it is funny)

[Serializable]
public class Person : Row
{
    public string nickName;
    public int age;
    public int height;

    // a bit of boiler plate required at the moment
    public Person(string prettyName)
    {
        this.prettyName = prettyName;
    }
}

The Browser window

Allow you to add rows, browse/edit your data. Don't forget to hit save when done! (Will either implement auto save or tint the window when a change is detected very soon)

Browser window Gif

Cross referencing rows

If you wish to reference a row from any other row (whether they share the same type or not) you'll need to create an empty class like:

[Serializable]
public class PersonReference : RowReference<Person> {}

This will allow you to that:

RowReference Gif

Accessing a row by code

CodeCompletion Gif

Searching

IEnumerable<Animal> heavyAnimals = Table<Animal>.Rows.Where( animal => animal.weight > 5 );

Notes

  • It's still very much a work in progress
  • At the moment loading a table loads its entierty. So every row is deserialized and goes into memory. The experimental branch looks at pure streaming and would fix that issue but it's not ready yet.
  • SlugDB is designed for small to medium databases (at least at the moment) If you have to deal with json files that are 500MB it is not the right tool for you.
  • Odin is obviously not included in the repository and you'll get compiler errors when cloning/downloading until you import it to your project)
  • Minimum compatible version of Unity is 2018.3 since I'm using Addressables (via my ResourcesReference class).

slugdb's People

Contributors

pinkas avatar

Stargazers

Forrest avatar ZTIF avatar Jeff Campbell avatar harun seng avatar Jesse Talavera avatar  avatar Justin Wagner avatar Randall Fitzgerald avatar

Watchers

Justin Wagner avatar  avatar

Forkers

r2d2m

slugdb's Issues

Quick note on UI

Hey there,
I just wanted to mention, not sure if you are familiar with UIElements, but it makes the creation of things like this much more practical than it was with imgui. You can easily make reusable pools of preconstructed elements (such as for an entry in the DB, etc) and could help remove the dependency of Odin. I was able to create a fairly similar UI to Odins relatively easily.

Just wanted to share that info in case it could help out. ๐Ÿ‘
Thanks,
-MH

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.