Misc

← Back Editor assembly guide

Mostly, database works inside Editor assembly the same way as it works at runtime, meaning you can develop your own Editor tools on top of the database. Use generated classes to access database.

To save database in Unity Editor via C# code from Editor assembly, use this line:

    //This will work ONLY inside Unity Editor from Editor Assembly
    BansheeGz.BGDatabase.Editor.BGRepoSaver.SaveRepo();

To save database in Unity Editor via C# code from Runtime assembly, use this line:

    //This will work ONLY inside Unity Editor from Runtime or Editor Assembly
    BansheeGz.BGDatabase.BGUtil.SaveDatabaseInUnityEditor();

To assign unity asset field values, use SetAsset method, defined on each unity asset field and available in Editor assembly (this method is not available at runtime assembly)

    SetAsset(int entityIndex, UnityEngine.Object asset)

The method is defined at the base Unity asset field, which is BGFieldUnityAssetA<T> (T is the value type), so you need to downcast BGField to this class if you do not use CodeGen addon. If you use CodeGen addon, you can access the field directly without need to downcast, using {TableClass}._{fieldName} notation, see more details here

← Back to Misc