Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[RELEASED]Visual Item Database - Game Items Management and Editing Tool

Discussion in 'Assets and Asset Store' started by bloeys, Apr 13, 2016.

  1. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Hi,

    The Visual Item Database is an editor tool that allows game developers, both coders and non-coders, to easily create and manage all their game items(e.g. swords, hats, guns etc..) in one place, using an easy to understand yet powerful interface.

    No more need to go back and forth between programs that store your items (like excel) and unity constantly, get rid of the hassle of having to parse them and converting them to data you can use in your game.

    The Visual Item Database allows you to keep everything in one place, and all within Unity itself without requiring external programs. It also stores all your data in Unity formats like scriptable objects and prefabs, so loading is a breeze.

    Generic.PNG

    Though the database default item types have been made for RPG games, that does not mean you can’t use it for other types of games and items. The default item classes can all be changed to become another item type(E.g. guns, enemies...) or you can use your own custom classes.

    The addition and removal of item types and subtypes to the Visual Item Database is made very simple via a special ‘Item Type Control‘ window that enables you to easily add and remove item types/subtypes from the Visual Item Database, giving you total freedom with what you want to have. More details about this window are available in the associated documentation.

    Type Control V3.PNG

    In order to use your items you can create instances of them at runtime using a single method call. In addition to runtime instance creation, you can also create prefabs of items and update those prefabs at the click of a button or simply add items to existing objects instead of creating new prefabs for them, again by simply pressing a button.

    You can create thousands of items without worrying, and the Visual Item Database has been stress tested with over 10,000 items and it remained extremely stable with very little or no lag.

    So to summarize the main features of the Visual Item Database:-
    • An intuitive and easy to use graphical interface.
    • Support for thousands of items.
    • Freedom to add/remove properties of items.
    • Easily add/remove item types and subtypes using the ‘Item Type Control’ window.
    • The ability to have any number of subtypes for each main item type.
    • Item type groups that allow you to group your item types together for organization.
    • Auto-generated enums containing the names and IDs of all items in each item type.
    • Ability to update the prefabs of all the items of a type at the click of a button.
    • Retrieve items in code using their name or ID via a single method call.
    • Editable and versatile to suit your specific needs.
    • Thorough documentation for both programmers and designers.
    • Zero runtime overhead.
    • Support for Unity 4.7.1 and above.
    • Works in Unity free and pro versions.
    • Full source code.
    Read more here.

    The Visual Item Database tutorial series has started! Check it out below and learn all about the VID.



    You can also see the latest documentation here.

    I'm happy to hear your feedback!

    Changelog:-

    V1.1:-
    • Added the 'Item Type Control' window to make the process of adding/removing item types very quick and easy.
    • Added an 'About' window to help you know which version of the Visual Item Database you are using.
    • Changed position of the 'Add New Item' Button to be below the page buttons.
    • Included the updated documentation for version 1.1.
    V1.1.5:-
    • Revamped the version update system to make future updates much smoother and easier for the user.
    • Changed naming of things called 'Categories' to 'item types' to make things less confusing for some users.
    • Included the updated docs for V1.1.5.
    V2.0:-
    • Added Item Subtypes.
    • Added Item Subtype sections to the 'Item Type Control' Window.
    • New 'GetRandomItemCopy' method overload specifically for item subtypes.
    • Ctrl-Shift-E is now a shortcut for the 'Item Type Control' editor window.
    • Included the updated docs for V2.0.
    V2.5:-
    • Introduced the 'ItemDatabaseEditorWindowUser' file which contains methods that give the user the ability to add editor customizations directly into the item area of the database editor window.
    • Small optimizations to the editor window.
    • Removed some of the default properties of the 'ItemBase' class.
    • As always, included the updated docs for V2.5.
    V2.8:-
    • Added the 'GetAllTypeItems' and 'GetAllSubtypeItems' methods to give the ability to retrieve the instances of all the items in a type/subtype.
    • Fixed small subtype method bug and now requiring users to pass the main type to subtype methods.
    • Turned the 'ItemSystemUtility' class into a partial one to give the users the ability to add to it without losing their work upon updating.
    • You see, documentations really take a lot of work.
    V3.0:-
    • Added 'Type Groups' to allow easy grouping of different item types.
    • Added 'Item Names Enums' to allow selecting items from the inspector instead of having to edit code every time.
    • Now what subtypes an item belongs to are shown in the database window.
    • Fixed a Unity 5+ bug which produced a non-critical error.
    • Yup, updated docs are available too.
    V3.1:-
    • Added the 'GetAllSubtypeItems' method.
    • Added an overload of 'GetRandomItemCopy' for subtypes.
    • Fixed editor window crash when deleting last item of a subtype.
    • New Docs.
     
    Last edited: Dec 6, 2017
    theANMATOR2b likes this.
  2. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    304
    How does this compare to Inventory Pro on the asset store?
     
  3. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Hi,

    The Visual Item Database is fundamentally different compared to Inventory Pro, but it seems this is a common misconception.

    This asset is essentially a database, a central place to store/create/edit/access all your game items, which really can be anything which you want to have multiple versions(same script, different values). For example you can have a category for melee weapons, a category for guns, a category for potion, and if you want you can even make a category for your enemies where you have different enemies like say light/medium/heavy/ranged, where they might all use the same base script but each having different variables and values, so changing them and adding to them is a very simple process.

    Inventory Pro on the other hand is, like it says, mainly an inventory system, something in game, while this is a tool to help you make a game. Inventory Pro provides you an inventory system with additional stuff like vendors and crafting.
    It also takes a slightly different approach to items, where there you use its window to add properties to your items, while in the Visual Item Database your own classes are used as the base for the items and the properties in it are shown.

    Though this will probably be changing in the future since an update is planned to allow users to add/remove item properties from a window without coding, just as the update released a few days ago allowed the addition and removal of categories without touching any code.

    Inventory Pro is more focused on the inventory side of things while providing a way of dealing with items along with crafting, the Visual Item Database is way more focused and specialized into the area of handling and storing items while providing functions to easily access them and use them in game, though features to allow more functionality without dealing with code are coming.

    The specialization of this tool and the more general approach of the Inventory Pro can be seen in the stark price difference.

    I hope this has cleared your doubts, please feel free to ask any more questions you might have.
     
    Exeneva likes this.
  4. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    304
    Makes sense. So this is designed to be a database for items in the entire game.
    I am very intrigued now, but will wait for your future update before buying.
     
  5. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Thank you for your interest. I see that the ability to add/remove item properties without coding is very important to you, so I'll make sure to notify you when the update is out.

    In the meantime, please feel free to ask any more questions you might have.
     
    Exeneva and theANMATOR2b like this.
  6. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,032
    @bloeys
    Hope this is still being developed as it looks like it could be v useful.
    I'd be interested in this Asset to the extent it can help with items with a larger number of properties and attributes, types, subtypes. That sort of thing. Without coding would be a massive bonus on that.
    For the price, I might buy anyway...!
    [edit]
    Oh hell, just bought it anyway... ;) So please DO keep on with that development...
     
    Last edited: Jul 17, 2016
    bloeys likes this.
  7. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,032
    Some other ideas for further development - currency and conversion for value for items - buyable, sellable, lootable value:-
     
    bloeys likes this.
  8. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Thanks a lot for supporting me, I really appreciate it! and yes, it still is in active development!
    In fact an update was just submitted recently(awaiting approval) which will open the way for future updates to hopefully be very smooth and automated so that you don't have to worry about doing work when transffering items to a new database version.

    And thanks for your ideas, I'm always looking for more ideas and features to add. If you can please send me an email with a bit more detail on the features you would like to see in future updates I would appreciate it.
     
  9. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,032
    @bloeys ,
    I'll go have a play with this asset and let you have my views of potential lines to take on development...
     
  10. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,032
    @bloeys ,
    OK I've sent in some suggestions for developments for the Asset over your webpage and one minor error report by email too.
     
  11. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,707
    Just bought the asset & am just now starting to use it. So far I'm really liking this new asset. However, I do have one main feature request, and two minor requests.

    I'm using this not to hold all my items (I already have a system for that, so no need.) but to store all of my crafting database.

    I bought this asset for the "Visual" aspect. I liked the idea that the icons showed up in the database window, helping to organize the database by artwork. However, I'd like to use this exclusively for crafting. So I'd like to be able to see my ingredients as icons as well. Even better, if they could be displayed as a final icon set as shown.

    I have three requests, basically, but the main one is for a new type to be used in the item's data (an icon, (Feature #2)

    feature request.png

    Basically, it would look like this

    feature request 2.png

    Feature#3 seems a bit complex (allowing us to place both multiple Icon types & input text, in a single line), so that's not really as necessary. It's just a feature that I think would add a lot to this asset, for the future.

    My main requests are Feature #1 & Feature#2

    1) Making the icon / whole area bigger as an option (x2 or adjustable size - Feature#1)
    2) Adding in an "Icon" type, that does nothing more than allows us to easily place images in the actual item's data (as shown- Feature#2)

    Code (csharp):
    1.  
    2.     [System.Serializable]
    3.     public class IngredientRequired
    4.     {
    5.         public string Name;
    6.         public int Count = 1;
    7.         public bool Consumed = true;
    8.         public Sprite Icon; //The icon to display visually in the Unity Editor //Feature Request #2
    9.     }
    10.  
     
    Last edited: Aug 16, 2016
  12. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,707
    Ah, nevermind on Feature #1. Didn't realize the whole thing already scales when you change the image's size.

    That's one feature already down! :p
     
  13. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Hi,

    First of all thanks a lot for buying the Visual Item Database and supporting me, I hope you find it useful :).

    Feature 2 is doable, but because of unity limitations I can't directly put the image next to the field, but what I can do is give the option(a tick?) to show the sprite just below the item information, something like this:
    Capture.PNG
    Is this good?

    Feature 3, again, is also doable, in fact it is not hard to do at all, probably just a few lines of code!
    The issue though is in the fact that this is very case specific. For example most of the people using the asset use it for things other than just crafting items, like swords/clothes/ammo, so they wouldn't need such a thing. Putting this in will force those people to add extra information into their items that they do not need.

    Or their crafting system could be done differently so I this might actually hurt those users. But there is actually something else we can do(which can be a very cool addition to the VID).

    How about I give you access to a partial class with methods called at certain times allowing you to further modify the VID. For example you can have a method that is called directly after an item is shown, so anything you put there will appear after the item information, giving you absolute freedom with what you want to do or show then!

    In fact I got it working now ;D, have a look:
    Capture2.PNG
    Here is the only code I had to type (most is GUI code):
    Capture3.PNG
    It looks a bit ugly but this is just a quick and dirty prototype, you can make it look however you like!
    This method will be called right after the selected item is shown, the passed parameter is the currently shown item, which I cast to "NewType" (which is the type I created to hold your recipe) so I can access non-generic properties, in a normal case though where you have multiple types you would need to check to know which type to cast to.

    I hope this helps and proves a useful feature for you and other devs. It will hopefully be coming in the upcoming update, which will also hopefully have another new feature called 'Type Groups', along with this.

    If you enjoy the VID please don't forget to give a review as it really helps.
    Feel free to ask anymore questions you might have :)
    bloeys
     
    CarterG81 likes this.
  14. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,707
    Sounds great for Feature#3. Exactly what is best, so we can choose whether or not to customize it ourselves if we need. I already did something similar, but I'm unfamiliar with the Unity Editor GUI api, so I have huge gaps between my sprites.

    ex2.png

    But your example is cleaner & definitely works just as people will need (or not) in the future. Perfect solution for the future of the asset. I also definitely like it better above all the prefab buttons.


    Unfortunate that Feature#2 (icon displaying directly underneath where it's assigned) is not possible in Unity. But Feature#3 is pretty much all that is needed anyway, now that I think about it.

    Looks great to help me visually display the ingredients for each recipe.

    Thank you! :)
     
    Last edited: Aug 16, 2016
  15. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,707
    This tool has also inspired me to add in "image comments" to Visual Studio 2015. I've always liked the idea of dropping in images to Visual Studio, and honestly can't believe this isn't already a feature long ago. Images really help to more efficiently (quickly) understand what is going on, rather than having to read tons of text and programmer interfaces.

    That is why I like this product. It is also motivating to see your image icons in the Visual Item Database, rather than it just being a ton of soulless text (like a XML/JSON file).

    Once I get my crafting system setup, I will definitely give this product a thorough (positive) review. Out of every solution I could find, this one definitely seems to be one of the strongest. I just wish it were around before I created my item system too. Then I could use it for both crafting recipes & all my items ;)
     
  16. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    This is awesome! I'm glad you liked the idea!

    Don't worry about the huge spaces, that is easily fixed. When you are using something like GUILayout or EditorGUILayout to add items to the editor window in Unity, it will usually fill out all the space it can, so(if you want) you need to limit how wide/high something can be, which is easily done by simply adding something like GUILayout.Width()/GUILayout.Height() to the end of a methods main arguments (where it says GUILayoutOption) to give an absolute size, as you can see I have done in the code picture in my previous post.

    I took a look at this VS extension and it lookd like it could be really useful! I have never imagined images in something like VS haha, an image in a world of text. Though like you said images really do give an instant idea and understanding, instead of reading carefully to get whats happening. Like they say, an picture is worth a thousand words.

    Its really cool to see someone else using the VID, makes it all worth it :), I hope you continue to find it useful. Thanks a lot for your support!

    P.S: If you can I would recommend holding out until I release the next update instead of adding your code now since adding it now it will get it overwritten when the new update rolls out.(In addition its a bit hard I believe finding where to put it in that huge code file and how to get the item to use haha)

    EDIT: Fixed a few mistakes
     
    CarterG81 likes this.
  17. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,707
    I noticed that there are no functions to sort through the entire list of items, all of a certain type, or all of a certain subtype.

    The only functions I see are to get very specific items (one item) by name/ID & type.

    I think it would be good for the future of the asset to have these functions.

    I'd add it myself, but I see there's a lot of code generation & warnings to not modify it in the documentation. So I'd rather wait for an update than write a lot of this myself & break the code generation. I'd iterate through all ID's (loop) using the current method to get items, but the ID"s are randomly generated from any possible INT, so it doesn't start at 0. (I don't really see the point in random int values, rather than incremental values starting from 0, but no problem if these functions existed.) edit: Er, maybe I'm just too sleep deprived to see that last part clearly.

    I need functions that allow me to

    1) Get all items of a certain Type.
    2) Get all items of a certain SubType of Type.
    3) Get all items in the entire database (not required, since I could just iterate through #1 with all Types).

    Although this is a bit unique to my use of it as a crafting system, I think this could be useful for others, if they were to use Types/Subtypes for Merchants/Stores or sets of random loot in specific game areas. (More complex randomness, derived from getting all loot of a type/subtype. I know there's already the getRandom of a type.).

    I might be too sleepy to get this right, but I believe it's something like

    Code (csharp):
    1.  
    2. ///ItemSystemUtility
    3.  
    4. //Get All Items by Type
    5. public static List<ItemBase> GetAllItems(ItemType type)
    6.         {
    7.             List<ItemBase> items = null;
    8.  
    9.             //Instantiate item of proper type
    10.             switch (type)
    11.             {
    12.                 case ItemType.Recipe:
    13.                     items = new List<ItemBase>();
    14.                     break;
    15.                 case ItemType.Basic:
    16.                     items = new List<ItemBase>();
    17.                     break;
    18.             }
    19.  
    20.             #if UNITY_EDITOR
    21.             if (!itemDatabase)
    22.                 LoadItemDatabase();
    23. #endif
    24.  
    25.             //Get the items
    26.             items = itemDatabase.GetAllItems(type);
    27.  
    28.             if (items == null)
    29.                 return null;
    30.  
    31.             return items;
    32.         }
    33.  
    34. //Get all Items by SubType
    35.         public static List<ItemBase> GetAllItems(string subtypeName)
    36.         {
    37.             List<ItemBase> items = null;
    38.             ItemType mainType = 0;
    39.  
    40.             //Get main type
    41.             for (int i = 0; i < vidLists.subtypes.Count; i++)
    42.             {
    43.                 if (vidLists.subtypes[i].name == subtypeName)
    44.                 {
    45.                     mainType = vidLists.subtypes[i].type;
    46.                     break;
    47.                 }
    48.             }
    49.  
    50.             switch (mainType)
    51.             {
    52.                 case ItemType.Recipe:
    53.                     items = new List<ItemBase>();
    54.                     break;
    55.                 case ItemType.Basic:
    56.                     items = new List<ItemBase>();
    57.                     break;
    58.             }
    59.  
    60.             #if UNITY_EDITOR
    61.             if (!itemDatabase)
    62.                 LoadItemDatabase();
    63.             #endif
    64.  
    65.             for (int i = 0; i < vidLists.subtypes.Count; i++)
    66.             {
    67.                 //Find the subType and get all item id's from that subtype
    68.                 if (vidLists.subtypes[i].name == subtypeName)
    69.                 {
    70.                     foreach(int id in vidLists.subtypes[i].itemIDs)
    71.                     {
    72.                         items.Add(itemDatabase.GetItem(id, vidLists.subtypes[i].type));
    73.                     }
    74.  
    75.                     return items;
    76.                 }
    77.             }
    78.  
    79.             return null;
    80.         }
    81.  
    82. ///ItemDatabaseV2
    83. public List<ItemBase> GetAllItems(ItemType type)
    84.         {
    85.             switch (type)
    86.             {
    87.                 case ItemType.Recipe:
    88.                     return autoVidLists.autoRecipe;
    89.  
    90.                 case ItemType.Basic:
    91.                     return autoVidLists.autoBasic;
    92.             }
    93.  
    94.             Debug.LogError(string.Format("Item of Type '{0}' Does NOT exist", type.ToString()));
    95.             return null;
    96.         }
    97.  
     
    Last edited: Aug 20, 2016
    bloeys likes this.
  18. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Awesome suggestions and even pseudo code? gotta love this!

    I never imagined anyone would want to get an entire type/subtype, but you actually give quite good reasons for one to do so. That is why feedback like this is so important.(Thanks!)

    As far as editing your self, please feel free to edit whatever you want, the only point is that you don't change anything having comments starting with "//#VID-". For example this GetItem method:
    Code (CSharp):
    1. public static ItemBase GetItemCopy(int id, ItemType type)
    2.         {
    3.             ItemBase item = null;
    4.  
    5.             [B]//Everywhere is OK except for between those two //#VID- comments[/B]
    6.             //Instantiate item of proper type
    7.             switch (type)
    8.             {//#VID-GICB
    9.                 case ItemType.YourType:
    10.                     item = new NewType();
    11.                     break;
    12.             }//#VID-GICE
    13.  
    14.             [B]//You can add Below or Above the switch-case and you are fine[/B]
    15.             //This is because in game we don't need this check, since we assume that the ItemSystemUtility is attached to a gameobject
    16. #if UNITY_EDITOR
    17.             if (!itemDatabase)
    18.                 LoadItemDatabase();
    19. #endif
    20.  
    21.             //Get the item we want to become
    22.             ItemBase itemToCopy = itemDatabase.GetItem(id, type);
    23.  
    24.             if (itemToCopy == null)
    25.                 return null;
    26.  
    27.             //Become that item
    28.             item.UpdateGenericProperties(itemToCopy);
    29.             item.UpdateUniqueProperties(itemToCopy);
    30.             return item;
    31.         }
    Now as far as iterating goes, you don't actually need to know the IDs, you have direct access to all the lists containing your items. Each type has its own list which can be found in the VIDItemLists class. So to get a list of (instanced) items of a type all we need to do is to choose the list to iterate over, get each item, make an instance of it and add it to a list and you are done. In fact:
    Code (CSharp):
    1. public static List<T> GetAllTypeItems<T>(ItemType type) where T : ItemBase, new()
    2.         {
    3.             List<T> items = new List<T>();
    4.             T instance = null;
    5.  
    6.             switch (type)
    7.             {
    8.                 //Iterate directly over all the items of the wanted type, make instances of them and add them to the list
    9.                 case ItemType.YourType:
    10.                     for (int i = 0; i < vidLists.autoYourType.Count; i++)
    11.                     {
    12.                         instance = new T();
    13.                         instance.UpdateGenericProperties(vidLists.autoYourType[i]);
    14.                         instance.UpdateUniqueProperties(vidLists.autoYourType[i]);
    15.                         items.Add(instance);
    16.                     }
    17.                     break;
    18.             }
    19.  
    20.             //Finally we return the wanted list, no casting required ;)
    21.             return items;
    and you are done :p(not tested). and with the magic of generics, you get the derived type directly!
    Though I'll look into how it could be made more efficient since types can get quite big and all. Subtypes are a similar idea. Subtypes are simply lists of IDs, so just iterate over a subtype, use the id to get an item and make an instance of that and you are done(basically like what you did). Of course I'll have methods for all of those ready!

    You are right about the ID thing, though I didn't make it like that for a few reasons. Yes incremental ids do look good on paper, but when you consider item moving(physical list relocation), deletion and duplication(insertion not at the end of the item list) you realize that the dream of id being list position or anything like that is long gone. Another thing is, how do we know what is the highest id so we can increment on? we can't naively use the item count and increment on that, because if an item was deleted then we would get a duplicate ID.

    Mainly these issues (and the fact that there is no real advantage to having incremental IDs) lead me to get a random ID, a number between the minimum/maximum int values, about 4 billion unique numbers, you are not going to get a collision any time soon ;) (yet I do make sure that the random number I get is not currently in use :p)

    I don't think I'll have one where it returns a list of absolutely everything, it will just be a mess I guess, but like you mentioned, getting lists of each type independently would have the same effect.

    I'll make sure to include those things in the next update. Many thanks for your suggestions, you are really helping to improve the VID! Also if you are finding the VID useful please consider leaving a review as it really helps.

    Regards!

    Edit: forgot/fixed something
     
    Last edited: Aug 20, 2016
    CarterG81 likes this.
  19. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,707
    Thank you. That makes a lot more sense than what I was thinking. I was too sleepy to see typesOfUsedIDs existed.

    However, if I understand correctly, if I have one Subtype in two different Types, the logic in GetRandomItemCopy() will only return random tiems from the first found Type.

    Type: Weapons; SubType: Sword
    Type: EnchantedItems ; SubType: Sword

    GetRandomItemCopy("Sword"), would result in a random item from only Weapons:Sword.
    0% chance it will ever pull from EnchantedItems:Sword.

    Code (csharp):
    1.  
    2.         /// <summary>
    3.         /// Returns a copy of a random item from the passed subtype(use the subtype enums and convert the wanted subtype to a string)
    4.         /// </summary>
    5.         /// <param name="subtypeName">Name of the subtype</param>
    6.         /// <returns></returns>
    7.         public static ItemBase GetRandomItemCopy(string subtypeName)
    8.         {
    9.             ItemBase item = null;
    10.             ItemType mainType = 0;
    11.  
    12.             //Get main type
    13.             for (int i = 0; i < vidLists.subtypes.Count; i++)
    14.             {
    15.                 if (vidLists.subtypes[i].name == subtypeName)
    16.                 {
    17.                     mainType = vidLists.subtypes[i].type;
    18.                     break;
    19.                 }
    20.             }
    21.  
    So I was thinking

    Code (csharp):
    1.  
    2.         /// <summary>
    3.         /// Returns a copy of a random item from the passed subtype(use the subtype enums and convert the wanted subtype to a string)
    4.         /// </summary>
    5.         /// <param name="subtypeName">Name of the subtype</param>
    6.         /// <returns></returns>
    7.         public static ItemBase GetRandomItemCopy(string subtypeName)
    8.         {
    9.             List<ItemBase> items = new List<ItemBase>();
    10.             List<ItemType> mainTypes = new List<ItemType>();
    11.  
    12.             //Get main type
    13.             for (int i = 0; i < vidLists.subtypes.Count; i++)
    14.             {
    15.                 if (vidLists.subtypes[i].name == subtypeName)
    16.                 {
    17.                     mainType.Add(vidLists.subtypes[i].type);
    18.                 }
    19.             }
    20.  
    and of course, the proceeding logic to find all the items & pick one random from "List<ItemBase> items".

    Unless you don't want this behavior, or want this as another function

    Code (csharp):
    1. public static ItemBase GetRandomItemCopy(string subtypeName, ItemType type) //Get from specific type.
    2. public static ItemBase GetRandomItemCopy(string subtypeName) //Get from ALL types.
    I'm not thinking about it in depth, but I believe this would be a good function to expand SubTypes feature.
     
    bloeys likes this.
  20. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,707
    BTW, I don't need this function. I just noticed it may cause an issue later on, if someone were to have the same subtype in two different types & used that function.

    Everything seems to be working great for me now. Will review when I'm finished, which is pretty soon.
     
    bloeys likes this.
  21. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Haha yea, 'typesOfUsedIDs' does actually exist. It and 'usedIDs' are actually two parallel lists, so you can iterate over one and use the index of one to get the value in another. This way I can know what type an item is just by its ID.

    The subtype thing is a very nice catch indeed. While working(just before your post) on implementing the new get all items methods for types/subtypes I noticed this oversight on my part. I will update the methods to require the user to pass in the main type as well. Not only is this more efficient (no iteration) but it fixes this issue as well.

    Now I get your point about choosing from a few types but I don't think this is a good idea. Aside from the confusion such a thing might cause, you have to think about how people call such a method. You use enums made specifically for a certain main type, that means when the user calls it he already expects to get an item of a certain type, so returning some other type can be very confusing, error prone and hard to debug.

    So just like the new get all subtypes method I will make it require that a main type is passed as well. Hope this doesn't affect you negatively!

    Edit: Just read your new post, if you are talking about the multi-type subtype method, then you just got the same idea as I did. Also I appreciate you taking the time to review, its awesome of you :)
     
    CarterG81 likes this.
  22. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,707
    Awesome. That is good to know.

    None of it affects me negatively. I understand all the code now, so I can edit it as I need, one way or another. I've already got it all working (from what I can tell so far), so no rush on your part for that update. I've created all the functions I need, for now.

    Thanks again for all the tips/updates.
     
    bloeys likes this.
  23. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,032
    ... although I wouldn't mind that increased functionality... ;)
     
  24. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Well....but you do realize that for it to have any real effect you will need to have multiple types that have subtypes with the same name. If this is fine with you I can add it no prob.
     
  25. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,032
    It could be useful...
     
  26. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    No problem then. For now I have submitted a new update with the new all items in type/subtype methods, so I'll hopefully include this one in the one after it.;)
     
  27. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,032
    @bloeys ,

    Just downloaded the latest version.

    Any chance of Playmaker action and integration for v4 ?
     
  28. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    @Duffer123 Hey that's awesome, hope you enjoy it :)
    The new item enums are especially cool so make sure to check them out!

    About playmaker, well I am not sure to be honest. I haven't used it before so I'll have to test it out and then see what I can do, so nothing for sure yet.

    But can't playmaker interact with the VID already? I mean it's just function calls to ItemSystemUtility, now I don't know how playmaker works but I assume it can do that right or do you have something in mind?
     
  29. TenderLoving

    TenderLoving

    Joined:
    May 11, 2017
    Posts:
    2
    @bloeys

    I'm having a problem where the VID is not accessed in build. I made a simple test project with a single scene and a Text object. The below code will show "Test Armor" in the editor game mode, but in build it just shows "new text."

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using ItemSystem;

    public class VIDTest : MonoBehaviour
    {
    public Text text;
    public ItemArmor armor;

    void Start()
    {
    armor = (ItemArmor)ItemSystemUtility.GetItemCopy("Test Armor", ItemType.Armor);
    text.text = armor.itemName;
    }
    }

    Is there something I need to do to expose VID to the game build?
     
    Last edited: May 11, 2017
  30. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Hey, sorry for your trouble, lets try to fix this!

    did you add the ItemSystemUtility Prefab to the scene? this is required in each scene. Aside from this there is no special requirement for builds or anything like that. Hopefully this fixes it, otherwise we will look deeper into it.
     
  31. TenderLoving

    TenderLoving

    Joined:
    May 11, 2017
    Posts:
    2
    That worked.
     
  32. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    176
    This asset so far is amazing. I was hesitant since nobody said anything in this thread for quite some time.

    I'll change that for when someone else comes in here.

    I'm using 2017.3.0p4 and it works perfectly so far. I cannot speak for older or newer versions of Unity. The reason I like this asset so much is that this is the asset I needed. I was thinking about using Ork, RPG All-In-One or Inventory Pro just to name a few. In the end I settled with this.

    Those others are likely all fine assets (I don't own RPG All-In-One). If you need polished products that offer a wide range of features those can help a lot (Ork is almost overwhelmingly feature packed).

    Then there's Visual Item Database. The main thing about this is it's insanely easy to organize everything. Then just watching the developers three youtube videos about the asset makes it easy to extend everything.

    I hope the developer keeps updating the asset. I know there have been asset creators who've gotten discouraged partially by Unity's updates. However, this is an asset that I hope continues on for the life of my project.

    Thanks.
     
    bloeys and CarterG81 like this.
  33. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Thank you so much for the kind words, it is really nice to see people interacting on the forums, because like you said not much happens here.

    I am really glad you are enjoying the VID, and I hope you continue to do so. Also, rest assured that support for the VID isn't going away anytime soon, and it has support for Unity versions from 4.7.1 all the way to the latest release!

    As always if you have any issues, you know what to do ;)
     
    MrIconic likes this.
  34. rmorph

    rmorph

    Joined:
    Apr 3, 2012
    Posts:
    21
    Hi! I'm really interested in this asset. I understand that I do need a database at the back end of my game - which would be a large multiplayer / persistent world kind of thing. . but not having a DBadmin/programmer background Im very nervous about getting caught up in the complexities of Database management, so having a visual front end would be a great help.


    I wonder though a little bit about scaling. Is this Database meant to sit alongside for example a mysql (lite) database from ummorpg - or can it be integrated into that? Also there are tools for importing / exporting a large amount of data from excel (sheets of items) into SQL that I thought were useful. Possible to do the same thing here?

    Basically if you had the time could you please describe the pros and cons of this system vs dedicated databases... or even better how the integration would work.
     
  35. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Hello @rmorph

    Thanks a lot for your interest. I apologize for the late response, I will try to hopefully clear your doubts.

    Now by default the VID is meant to be a complete, standalone database system. As such, there is no support for other systems by default, although that does not mean you can't do that, its just that you have to do it by yourself.

    As far as scaling goes, the VID is definitely made for a huge number of items (tested with 10,000) so you shouldn't have a problem there. SQL is not supported, however management is done via other features of the VID, which are categories, subtypes and the item enums.

    While you might only have a few categories, you can have potentially hundreds of subtypes per category, which you can then use to easily get related items, combinations of items (armor set?) etc...

    You also have the item enums, which are enums per category that contains all the items (name+ID) of that category, which is used to get items from the database. So what you can do is to have say lists of these enums to make a combination of items. So there is a good amount of freedom you have in relation to item management and retrieving items which can act as a substitute for SQL commands.

    Importing/exporting is not supported, however should be relatively easy to implement, especially if you use Unity's JSON serializer.

    Of course your specific case and usage might vary, and there might be some other things that you like/dislike, so if you like I can send you a copy of the VID to your email and then you can use it and see if you find it useful for your case. If you then like it you can buy it from the asset store (please do, all support is useful ;) )

    If you would like a copy to play with please send me an email on bloeys@outlook.com
     
    Last edited: Oct 7, 2018
  36. qqqbbb

    qqqbbb

    Joined:
    Jan 13, 2016
    Posts:
    109
    How is database stored? Scriptable object ?
     
  37. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Yes, all items are completely contained within one scriptable object.
     
  38. qqqbbb

    qqqbbb

    Joined:
    Jan 13, 2016
    Posts:
    109
    I wanna make ItemBase class more generic. Which fields can I delete without breaking anything?
     
  39. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Hey,

    you just need the following:

    * itemName
    * itemDescription
    * itemID
    * itemType
    * itemIcon
    * The two methods in that class
    - Remember to remove/add variables related to the ItemBase add from the 'UpdateGenericProperties' function.

    Everything else can be removed.
    Now aside from name, ID and type, even the other things can theoretically be removed, however you will need to edit the VID elsewhere, so I recommend keeping the things I listed.
     
  40. qqqbbb

    qqqbbb

    Joined:
    Jan 13, 2016
    Posts:
    109
    When you add a new type to the database an enum is created for it. Where in the code is this enum generated?
     
    Last edited: Dec 14, 2018
  41. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    The editor code is present in:
    Visual Item Database/Scripts/Editor/ItemDatabaseEditorWindow.cs

    Please see the this method in there:
    public void UpdateItemNamesEnum(bool allTypes)


    Hope this helps
    Please do consider leaving a review if you like the VID, and feel free to give me any suggestions or questions you might have ;)
     
  42. qqqbbb

    qqqbbb

    Joined:
    Jan 13, 2016
    Posts:
    109
    Some feedback:

    Something I'm surprised noone complained about before:
    When you add a new type to database there is no checking if the class inherits from ItemBase. It will be added to the database even If it does not .

    "Remove Type" dropdown menu should include only types present in database.
     
    Last edited: Dec 16, 2018
  43. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Thanks a lot for the feedback, and apologies for the late reply since I was away on holiday.

    That is true, however it is not very trivial to do this kind of check since the VID at that stage really doesn't have the class itself, only its source file. With that being said, I will keep this in mind for the next update of the VID ;)

    Now aside from that, I think the reason this wasn't ever noted is that it is very easy to fix. If this kind of error happens, you can simply edit your class to inherit from ItemBase and everything else will work normally. There is no persistent downside.

    Specifically about this, it is actually showing only things there. If you don't inherit then unity can't serialize properly and you won't see it in the database window, however it is still actually there.

    The VID generates a lot of code when you add a type, and all that setup is already done when you add it even if you can't see it. When you inherit and make sure your class is serializeable then you should see that the type is actually there.

    Hope this clarifies things. Please feel free to provide any other feedback and I will be happy to help :)
     
  44. Splatacat

    Splatacat

    Joined:
    Jan 10, 2013
    Posts:
    10
    Hi there, Thanks for a wonderful system, I bought it a while ago and am using it in a project now.

    One question, I have created custom classes as I need. I need to access these unique properties in code but can only seem to access the generic properties when I interact with the item container on a gameobject. Am I missing something to access the unique properties of an itemtype?

    Thanks
     
  45. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    Hey, thanks a lot for getting the VID :D
    I hope you will find it useful in your projects.

    Now this is due to the fact that the ItemContainer script has an 'ItemBase' class inside it, which you need to then cast to the specific type to use.

    Now obviously that is a pain, and this is one of the reasons using ItemContainer is not the recommended way of interfacing with the VID. It is better to get items through code by using the 'ItemSystemUtility' class at runtime, which also ensures you always get the updated item.

    To do that easily, use 'ItemNameEnums' (they have a section in the Docs with code examples). They are basically an enum per item type that contains all the items for that type, so it allows you to make a drop down menu in the inspector to choose your item, and then at runtime (say in the start method) you can load that item and you will get the correct type directly.

    I hope this helps :)

    Edit: Link to docs: https://bloeys.files.wordpress.com/2018/02/visual-item-database-documentation-v321.pdf
     
  46. Splatacat

    Splatacat

    Joined:
    Jan 10, 2013
    Posts:
    10
    Thanks for the reply, I'm not quite sure what you mean. I am needing to compare a value that is not in the itembase class but one in my custom class.

    I can compare a value to one in the itembase class.

    I can't see a way to do that with the ItemSystemUtility, but maybe I am just missing it.
     
  47. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    So first, I assume you added your custom class to the VID and can see it in the VID editor window correct?

    Now your custom class inherits from ItemBase, so ItemBase doesn't have your properties. Your problem happens because the item container only has item base, it does not have your custom class inside it and therefore you can only see the generic properties of the class.

    What you need to do is to convert (cast) ItemBase to your custom class, which you can do like this:
    Code (CSharp):
    1. MyCustomClass item = (MyCustomClass) GetComponent<ItemBase>().item;
    After it is converted you will be able to access all your custom properties on the class.

    However, the other thing I mentioned in my previous post was that this is not recommended in the VID, it is better to do something like this:
    Code (CSharp):
    1. using ItemSystem;
    2.  
    3. public MyTypeItems itemToLoad;
    4. MyCustomClass myItem;
    5.  
    6. void Start()
    7. {
    8.     myItem = ItemSystemUtility.GetItemCopy<MyCustomClass>((int)itemToLoad, ItemType.MyType)
    9. }
    What this will give you in the inspector is something like this
    upload_2019-1-5_19-48-29.png

    With this, you can easily change the selected item in the inspector and when you run the game the correct item will be retrieved from the VID with the correct type (access to all your custom properties) which you can directly use.

    You can of course use ItemSystemUtility at any point in your code to get items.

    Hopefully this will get you up and running with the VID. I also recommend having a look at the docs to learn about the different features available in the VID and for code samples.

    Please feel free to ask any other questions you have :)
     
  48. Splatacat

    Splatacat

    Joined:
    Jan 10, 2013
    Posts:
    10
    Yes that is correct.

    If I cast it as you say then I can access all my custom properties, thanks that works.
    May I ask why is it not recommended to cast it in VID? I would only cast it locally in the function for comparative purposes, and only if other conditions are met first.

    I am still confused as to how to use your recommended way because I am interacting with a gameobject from a prefab that I created and that I updated through VID so that it has the itemcontainer component added to the gameobject.

    On another note, is it possible to access a particular gameobjects item subytpe to compare if it is in a particular subtype?

    Thanks for all your help
     
  49. bloeys

    bloeys

    Joined:
    Aug 26, 2014
    Posts:
    55
    About the first part, well there are several reasons.

    One being that the items are always updated (you don't need to update prefabs). Second is that you don't have tons of prefabs around. Third is that there is a potential performance benefit since you don't have extra Monobehaviors and no GetComponent calls. Fourth, is what if you want more than one item per object? well it gets a bit complicated, since its more work to get the one you want exactly. Fifth, is that casting to your custom type can get hard when you have more types since you have to check what type it is, while if you use the other method the VID does all the work for you.

    Those are what come to mind. Now other benefits of using the second method that I showed is that you have easy access from the inspector to change what item should be loaded and is faster than changing the container from the VID window. Also, any changes you make to items in the VID are automatically seen in the game without you updating containers from the VID.

    With that being said, that does not mean you should never use the prefab system, after all I don't know about your use case and what type of systems you are doing. Maybe you can start with that and learn with it and change later when you start facing issues with this system.

    Personally, I think that if you have a complex use case for VID (many item types, multiple items per object, a lot of items, big game etc...) it is better to use item name enums.

    There is no utility method for this (will make a note to add it for the next update), but you can do it like this
    Code (CSharp):
    1. //Best to use the subtype enums to get the subtype name
    2. public bool ItemInSubtype(ItemBase item, string subtypeName)
    3. {
    4.     //Find the subType
    5.     for (int i = 0; i < ItemSystemUtility.vidLists.subtypes.Count; i++)
    6.         if (ItemSystemUtility.vidLists.subtypes[i].type == item.itemType && ItemSystemUtility.vidLists.subtypes[i].name == subtypeName)
    7.             return ItemSystemUtility.vidLists.subtypes[i].itemIDs.Contains(item.itemID);  //Check if the item is in the subtype
    8.  
    9.     return false;
    10. }
    Now I just wrote this on the fly and haven't tested (don't have VID on this machine) but it should work. Simply pass any item and the subtype you want to check for.

    Hope this solves it, I will try to include this in the next update. If you find the VID useful please consider leaving a review here and feel free to provide further feedback or ask questions.
     
  50. Splatacat

    Splatacat

    Joined:
    Jan 10, 2013
    Posts:
    10
    Thanks for all your help so far.
    With experimenting i was able to come up with this variation to use ItemSystemUtility and nor to cast, and its directly related to what item and gameobject I am interacting with.

    Code (CSharp):
    1. ItemBuilding hitItem = ItemSystemUtility.GetItemCopy<ItemBuilding>((int)hit.transform.GetComponent<ItemContainer>().item.itemID, ItemType.Building);
    And your subtype comparing bool works perfectly, thanks for that. I have what I need to go further, I will ask again if I am unsure of something.
    I will be sure to leave a review on the asset store :D