Database Names Generator

Poiu

New member
Hello.
I have seen some post here at forum (quote below) about Database Names Generator and there is script responsible for editor, but I wonder how to run it?

To get attributes on ItemCategories and itemDefinitions is very similar.

As you see we use strings quite a bit to get objects and attributes. That can make it a bit of a pain if you are the type to make typos or forget how you named things. That’s why I made a script generator that extracts all the names of the objects in the database and auto generates them in hierarchy. All you have to do is press “Generate Name Script” in the editor Setup menu to get it.
 
Hi @Poiu

You can generate the C# script with all the names of the database using the cog icon in the setup menu of the manager:
1599035384981.png

The result will be something similar to this:
C#:
//This File is Auto-Generated by the editor window
//Date of creation: 02/09/2020 10:30:03
namespace Opsive.UltimateInventorySystem.DatabaseNames {
 public static class DragDropInventoryDatabaseNames
{
 //ItemCategories

public static class Viewable
{
 public const string name = "Viewable";//ItemCategory

//Attributes
public const string categoryIcon = "CategoryIcon";//Sprite
 public const string description = "Description";//String
 public const string icon = "Icon";//Sprite
 
//Item Definitions
 }

public static class Pickupable
{
 public const string name = "Pickupable";//ItemCategory

//Attributes
public const string pickupPrefab = "PickupPrefab";//GameObject
 
//Item Definitions
 }

public static class Shoppable
{
 public const string name = "Shoppable";//ItemCategory

//Attributes
public const string buyPrice = "BuyPrice";//CurrencyAmounts
 public const string sellPrice = "SellPrice";//CurrencyAmounts
 
//Item Definitions
 }

...

The name of the static class created is "<databaseName>Names"

Since it is a static script you can easily access it anywhere. For example to get the buyPrice attribute name:
C#:
MyInventoryDatabaseNames.Shoppable.buyPrice

For now if you wish to create an item you can do so like this:
C#:
var woodItem = InventorySystemManager.CreateItem(MyInventoryDatabaseNames.Material.wood);

In the future I will add more functionality to this generated script such that it'll make it very easy to reference your database objects.
 
Top