Skip to content

A simple way to create a database with global access and persistence, using ScriptableObjects

Notifications You must be signed in to change notification settings

LuizThiago/SimpleScriptableObjectDatabase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Simple Scriptable Object Database

A simple way to create a database with global access and persistence, using ScriptableObjects

Table of Contents
  1. About The Project
  2. Getting Started
  3. Contact

About The Project

The BaseDatabase<T> class provides a generic implementation for managing a collection of items of type T, where T must implement IDatabaseItem. It offers methods to add, remove, and search for items in the database, ensuring unique IDs for each item. It also includes support for data integrity in the Unity editor and can be easily extended for different types of databases.

(back to top)

Built With

  • C#
  • Unity

back to top

Getting Started

To get a local copy up and running follow these simple example steps.

Installation

  1. Download or fork this project
  2. Move the content to your Unity project (if preferred, only the Scripts folder is necessary)

(back to top)

Usage

  1. Create the ScriptableObject that will be responsible for storing and providing global access to all created databases, by right-clicking on the desired folder in the Project tab window and choosing the option Create > Database > Database Collection
  2. Create a new script that inherits from BaseDatabase<T>. Example: PlayerProfileDatabase.cs
    using UnityEngine;
    
    [CreateAssetMenu(menuName = "Database/Sample/Player Profile Database", fileName = "PlayerProfileDatabase")]
    public class PlayerProfileDatabase : BaseDatabase<PlayerProfile>
    {
    
    }
  3. Create an instance of the global variable by right-clicking on the desired folder in the Project tab window and choosing the option (in this example) Create > Database > Sample > Player Profile Database
  4. Give your new database a name, for example, PlayerProfileDatabase
  5. Assign the new instance of the PlayerProfileDatabase to the DatabaseCollection ScriptableObject
  6. Now, to access the PlayerProfileDatabase, in any MonoBehaviour script, you can use the static call
    DatabaseCollection.TryGet(out PlayerProfileDatabase playerProfileDatabase);

(back to top)

Contact

LuizThiago - @CodeLuiz - [email protected]

Project Link: https://github.com/LuizThiago/SimpleScriptableObjectDatabase

(back to top)

About

A simple way to create a database with global access and persistence, using ScriptableObjects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages