GameDB  1.6.0
GameDB Pro is a plugin that provides an easy to use and powerful game and meta data editor
GameDBEditorLibrary.GameDBEditor Class Reference

GameDBEditor provides static methods for working with the GameDB Editor within the Unity Editor. Allowing things such as subscribing to events (load/save/promote) and programatically working with the editor. More...

Static Public Member Functions

static bool LoadGameDB (string gameDBPath)
 Programatically load a GameDB in the editor. Useful if intergrating the GameDB Editor with other tools/editors. More...
 
static bool SaveGameDB ()
 Programatically save the currently loaded GameDB in the editor. More...
 
static void AddRowToTable (string table, string key, Dictionary< string, object > data)
 Allows the adding of a row to a GameDB table via an editor script. The GameDB needs to already be loaded via LoadGameDB method. After adding rows the GameDB needs to be saved via SaveGameDB More...
 
static void RegisterSavedGameDBCallback (Action< string > onSaved)
 Allows a callback to be registered when a GameDB has been saved in the editor. Useful for updating other editors or systems when data has changed. The Scope Name of the saved GameDB is returned via the callback. More...
 
static void RegisterRevisionPromotionCallback (Action< string, string, int > onPromotion)
 Allows a callback to be registered for when a revision of the GameDB is promoted on the GameDB Server. This is useful to trigger events such as causing live clients to update when a GameDB has been promoted. The Scope Name, tag and revision number are returned via the callback of the promoted GameDB. More...
 

Detailed Description

GameDBEditor provides static methods for working with the GameDB Editor within the Unity Editor. Allowing things such as subscribing to events (load/save/promote) and programatically working with the editor.

Member Function Documentation

◆ AddRowToTable()

static void GameDBEditorLibrary.GameDBEditor.AddRowToTable ( string  table,
string  key,
Dictionary< string, object >  data 
)
static

Allows the adding of a row to a GameDB table via an editor script. The GameDB needs to already be loaded via LoadGameDB method. After adding rows the GameDB needs to be saved via SaveGameDB

Parameters
tableThe table to add the row to.
keyThe key of the row to add.
dataThe dictionary representing the fields and data to add.
Exceptions
System.InvalidCastExceptionThrown when data of an invalid type is added for a field.
System.ArgumentOutOfRangeExceptionThrown when a field in the data doesn't exist in the table.

This example shows the code necessary to add a row to a table.

if (GameDBEditor.LoadGameDB("Test/testGameDB.json"))
{
GameDBEditor.AddRowToTable(TestSchema.TableName, "testKey1", new Dictionary<string, object> {
{ TestSchema.FieldTest1, "test" },
{ TestSchema.FieldTest2, true }
});
GameDBEditor.AddRowToTable(TestSchema.TableName, "testKey2", new Dictionary<string, object> {
{ TestSchema.FieldTest1, "test2" },
{ TestSchema.FieldTest2, false }
});
GameDBEditor.SaveGameDB();
}

◆ LoadGameDB()

static bool GameDBEditorLibrary.GameDBEditor.LoadGameDB ( string  gameDBPath)
static

Programatically load a GameDB in the editor. Useful if intergrating the GameDB Editor with other tools/editors.

Parameters
gameDBPathThe path to the GameDB to load.
Returns
true/false indicating success of the load operation.

◆ RegisterRevisionPromotionCallback()

static void GameDBEditorLibrary.GameDBEditor.RegisterRevisionPromotionCallback ( Action< string, string, int >  onPromotion)
static

Allows a callback to be registered for when a revision of the GameDB is promoted on the GameDB Server. This is useful to trigger events such as causing live clients to update when a GameDB has been promoted. The Scope Name, tag and revision number are returned via the callback of the promoted GameDB.

Parameters
onPromotionThe callback triggered on a promotion.

◆ RegisterSavedGameDBCallback()

static void GameDBEditorLibrary.GameDBEditor.RegisterSavedGameDBCallback ( Action< string >  onSaved)
static

Allows a callback to be registered when a GameDB has been saved in the editor. Useful for updating other editors or systems when data has changed. The Scope Name of the saved GameDB is returned via the callback.

Parameters
onSavedThe on saved.

◆ SaveGameDB()

static bool GameDBEditorLibrary.GameDBEditor.SaveGameDB ( )
static

Programatically save the currently loaded GameDB in the editor.

Returns
true/false indicating success of the save operation.