UIS with addressables - a few questions

Hi,

I have questions about UIS and Addressables. I know that UIS is not support addressables by design (currently). However, I see that
there are methods to add items category, definitions, etc. to database at runtime.

Is the following way will work?
1. Create items in UI,
2. Move items data to separate folder,
3. Mark them as addressables, e.g. for DLC
4. Load data with addressables system
5. Add them to UIS DB and use in the game


I see a few questions/problems:

1. To create item definition I have to use UI which means they will be added to DB. How can I remove it from DB but not from the project?
2. How the system will behave when I add dynamically items, save data and reload game? Is ID for item will change or will be the same?
3. How the system will react on name clash? For example, I add by accident an item with the same name that exist in DB?
 
As you said UIS does not support addressables for Inventory Object (Item Categories, Item Definitions, etc...) The thing that will cause you the less extra work is adding everything in the same database but keeping the items light weigth (don't reference assets directly), instead use string attributes as keys for your addressable objects, like sprites, prefabs, etc...

If you really want to prevent having those extra item definitions in because they will be part of a DLC then maybe there are other solutions.
I usually tell people to avoid using multiple database because causes issues with the custom inspectors that assume there is only one database.

But if you know what you are doing and you are willing to add some custom code I may recommend you to have a seperate inventory database for your DLC. Then you can load use a component that loads that extra database in the Inventory System Manager. Or you can replacce the Inventory System Manager by your custom manager. Having a custom managaer will give you a lot more controll on how inventory objects are loaded/initialized.

As you may suspect you might run into issues and we may not be able to help depending on how far you extend the asset.

As for your questions:

1) That's not supported by the Editor. One solution is to manually open the Database inspector in debug mode and remove the reference to the item definition... I'd highly recommend not doing this, it's more of a hack and could corrupt your database
2) When items are saved they are saved using IDs. Meaning that the ID must match the object (ItemDefinition, Item Category, asset guid, etc...) when it is loaded. Item Ids shouldn't change. Unique items will be given a unique ID when they are instantiated, as long as you are careful to not destroy it and replace it by an equivalent one with the same ID you will be safe.
3) If you try registering an ItemDefinition/ItemCategory with the same name as an existing one you will get an error saying that another object with the same name already exists, same thing with attribute names. You can check if an object with the same name already exists before adding one.

Side note: we did add support for people to add Item Categories and Item Definitions at runtime, but this is for very advanced users that know exactly what they are doing. So far very few users users that I know of have attempted this since it requires a faire amount of custom script to make it work properly and safely.

I hope that helps
 
Hi,

Thanks for info. Based on this info and my own code analyze we decided to make only one database to avoid too much extra work.

I set base as addressable and load it into system by
C#:
InventorySystemManager.Instance.AddDatabase(cc.InventoryDatabase);

I also added a field to avoid initialize base on game start:
C#:
/// <summary>
        /// Initilaizes the Manager using the database if one is specified.
        /// </summary>
        public virtual void Initialize()
        {
            CreateInventorySystemRegister();
            CreateInventorySystemFactory();

            if(_initializeBase)
            {
                if (m_Database != null)
                {
                    AddDatabase(m_Database);
                }
                else
                {
                    Debug.LogWarning("The database is null, please specify one in the Inventory System Manager.");
                }
            }

            m_IsInitialized = true;
        }

However, in build a get the following warning:
A different Opsive.UltimateInventorySystem.Crafting.CraftingCategory Herbs is registered with the same ID as Herbs, you may be referencing objects from the wrong database.

Can you tell me what is the problem here?
 
I'm not sure, perhaps it is an excution order problem. Double check that your inventiry system manager isn't being initialized before you expect it to be.

or perhaps it is a addressable issue where by mistake the system dupplicated the object within the inventory database, creating objects with the same name/ID but different references (I remember people having this issue in the Unity Open Source project with the pig, if i remember correctly they mention it in this video:
)
 
Top