Import from CSV file?

hanguang

New member
Hi,
Because the document is tooooo long, so while I'm reading it, I want to ask you guys directly.
With Definition and Category that are predefined in the database, is it possible that I can
construct an item at runtime that does not exist in the database.
If yes, how do I save it?

I'm currently using another inventory system (InventoryEngine).
I already have a CSV file, when import to Unity my script will convert it to InventoryItem.
How do I migrate them to UIS?
Or does UIS support creating items from a CSV file?
If yes, what are the best practices?

1609161363013.png

1609161373570.png

1609161383538.png

Guang
 

Sangemdoko

Moderator
Staff member
Currently UIS does NOT support imports or exports of item categories/definitions within a database.

You will need to create your items again from scratch using the UIS Editor Manager.

We are still looking into a good solution to import import/export items from/to a csv or json file. Due to the nature of Item Definitions inheriting attribute from Item Categories it makes things not so trivial. Adding this feature is in our TODO list but it is not one of the top priorities, so it may take a while before it is implemented.

You can create Items at runtime but only using an ItemDefinition within the database. These items can be saved using our save system which serializes the item attributes, ID and reference to its ItemDefinition.
 

hanguang

New member
I found a way to do it:
1.Create a Weapon category.
2.Create a Sword definition.
3.Put every attribute into runtime stats.

At runtime, create various Swords from CSV file (iron sword, wood sword, and so on).

@Sangemdoko
 

hanguang

New member
I got a problem:
The name of the item is the same as the ScriptableObject. Which is a problem for my solution.
I create items from the same definition with different runtime values include a name (string) attribute.
Could you please add a DisplayName feature for the item? Or show me how to do it.

@Sangemdoko
 
Last edited:

Sangemdoko

Moderator
Staff member
I'm surprised I didn't have a component for that before but I've just added this (it'll be part of the next update)

Code:
/// <summary>
/// Item View component displaying an attribute value.
/// </summary>
public class AttributeItemView : ItemViewModule
{
    [Tooltip("The attribute name. Must be an integer.")]
    [SerializeField] protected string m_AttributeName;
    [Tooltip("The attribute value text.")]
    [SerializeField] protected Text m_AttributeValueText;
    [Tooltip("Default text value")]
    [SerializeField] protected string m_DefaultTextValue;
    public string AttributeName {
        get => m_AttributeName;
        set => m_AttributeName = value;
    }
    /// <summary>
    /// Set the value.
    /// </summary>
    /// <param name="info">The item info.</param>
    public override void SetValue(ItemInfo info)
    {
        var attribute = info.Item.GetAttribute(m_AttributeName);
        if(attribute == null){ return; }
        m_AttributeValueText.text = attribute.GetValueAsObject()?.ToString();
    }
    /// <summary>
    /// Clear the value.
    /// </summary>
    public override void Clear()
    {
        m_AttributeValueText.text = m_DefaultTextValue;
    }
}

This Item View will show the value of an attribute as text, in your case the name.

If you were using AttributeViews instead of Item Views you could have used the existing "ValueAttributeView".

If you aren't familiar with Item Views and attribute views check this video tutorial:
 
Top