Search Unity

The InventorySystem C# - Unity5 - UGUI - Extremely extensible

Discussion in 'Works In Progress' started by jorisshh, Mar 3, 2015.

?

What's your biggest issue with this package?

  1. To expensive!

    33.3%
  2. Not enough features

    33.3%
  3. It's not something I'd buy

    33.3%
  4. Other, please leave a comment

    0 vote(s)
    0.0%
Multiple votes are allowed.
Thread Status:
Not open for further replies.
  1. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,520


    I launched a new Unity 5 Asset store package, an event driven Inventory system with loads of features build on Unity's new UI system.

    >> Asset store <<
    >> The demo <<



    In development:
    Crafting system with blueprints and categories. (Crafting, tailoring, etc...)
    Playmaker support

    Current features:
    Written in C#
    Mobile ready
    Fully customizable
    Looting
    Multiple inventories (Restrict inventory to categories and items of the category will be placed in it).
    Context menu (Right click item menu)
    Vendor system (NPC buying selling + buy back)
    Using / equipping items
    Skillbar with references
    Bank storing
    Unique item properties
    Stacking items
    Item categories with category cooldown
    Unstacking items
    Drop dialog
    Unstack dialog
    Item toolips
    Extending with bags (PRO ONLY!)
    Cleanup inventory (PRO ONLY!)
    Editor - Item creator
    Editor - Category creator
    Editor - Rarity creator
    Code - Event driven design
    Code - Extremely extensible
    Code - Well documented
    Code - uGUI (Unity GUI)
    Design - Complete RPG UI design (PRO ONLY!)

    Want to request a feature or report a bug? Please go to https://bitbucket.org/jorisshh/inventorysystemv2/issues

    Don't want to miss a thing?
    Stay updated through the mailing list.

    Completely Unity 5 ready.
     
    Last edited: Mar 17, 2015
    GibTreaty likes this.
  2. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,520
  3. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,520
    Mobile support has been added to the InventorySystem, now 100% mobile compatible :).

    Simply define the mobile triggers inside the Settings manager and you're good to go!
     
  4. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,520
    An in-depth look about customization

    Collections:
    All windows that can contain items are called "Collections". A collection is basically a glorified array that holds all the items and allows stacking, merging, swapping, etc. The basic collection (class ItemCollectionBase) has some default settings that allow quick and easy tweaking without having to dive into the code.

    • useReferences - This doesn't directly store the items inside the collection. When an item is placed inside the collection a reference is created.
    • InitialCollectionSize - This sets the size of the collection when the game starts. You can change this at run-time but be sure to instantiate UI elements accordingly (check documentation for more info).
    • container - The container is the parent of all inventory slots. You can easily create a grid / horizontal or vertical layout by using uGUI's buildin automatic layouts.
    • onlyAllowItemsOfType - This allows you to block items to a certain type. For example when extending the inventory there are 4 slots to place bags, by using the onlyAllowItemsOfType the collection can easily be limited to items of type bag. Example: This can also be useful if you want to limit a bag to only allow potions or consumable goods.
    • canDropFromCollection - Can you drop directly from the collection? Ignored if useReferences is enabled.
    • canUseFromCollection - Can an item be used directly from the given collection? Example: Can you use a potion directly from the bank?
    • canDragInCollection - Can items be re-arranged inside the collection? Disable if you want to have a static collection that the user cannot modify. For example a loot window.
    • canPutItemsInCollection - Can the user put items inside the collection or is it read only?
    • manuallyDefineCollection - If you don't want your collection to be auto-generated you can manually define it inside the Unity inspector.



    Interface:
    The interface is setup inside uGUI and is therefore completely adjustable to your needs. If you don't want to use certain elements, simply leave them empty, the system will handle the rest :).


    Tooltips
    Tooltips are shown when the user hovers over an item icon. These tooltips can be modified per item type. For example a consumable item might want to show how much health it regenerates while a weapon would likely want to show how much damage it deals.

    By default the tooltip shows some basic information, but you are in no way forced to use these.

    ConsumableInventoryItem (example item in project)

    Code (CSharp):
    1.  
    2.     public override LinkedList<InfoBox.Row[]> GetInfo()
    3.     {
    4.         var basic = base.GetInfo();
    5.         basic.AddFirst(new InfoBox.Row[]{
    6.                 new InfoBox.Row("Restore health", restoreHealth.ToString(), Color.green, Color.green),
    7.                 new InfoBox.Row("Restore mana", restoreMana.ToString(), Color.green, Color.green)
    8.             });
    9.  
    10.         return basic;
    11.     }
    12.  
    Each InfoBox.Row is treated as a row inside the UI, each row is separated by a euh.. separator. Obviously this is also modifiable.

    Inside the UI element you can define the layout and design of the tooltip.


    Extending the code
    (Almost) all classes inside the InventorySystem are marked partial. This means that if you create a class with the exact same name you can add functionality to the core features all without overriding core code. The compiler will auto. merge the files together. I highly encourage you to use this method, because it is the safest way to avoid problems with updates and conflicts.

    Example: So how does it work?
    The core system has 5 default item types.

    Let's say for the sake of this sample that we want to add extra functionality to the Consumable item type.

    All we have to do is create a new C# class and name it "public partial class ConsumableInventoryItem". Check the example below for a simple implementation.

    Code (CSharp):
    1.  
    2. public partial class ConsumableInventoryItem
    3. {
    4.     public int restoreDexterity;
    5.  
    6.     public void DoSomeAction()
    7.     {
    8.  
    9.     }
    10. }
    11.  
    All consumable items now contain a variable restoreDexterity and have an extra method DoSomeAction().
    This works with (almost) all core classes of the InventorySystem.
    Of course you also have the ability to inherit and override core functionality by using the override keyword in you classes.
     
  5. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,520
    I will likely start production on the NPC buying & selling with buy back in the upcoming week, as this is a commonly requested feature.

    If anyone wants to make specific requests regarding the buying / selling, please do so now :).
     
    Gekigengar likes this.
  6. goldencruz

    goldencruz

    Joined:
    Oct 2, 2013
    Posts:
    94
    look great
     
  7. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,520
  8. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,520
    A little update.

    Message center
    Messages and be displayed through the message center. Each message can of-course be fully customized, if you have your own message center / system you can simply hook to the event and transfer them to your own system.


    Item usage override

    The item usage as well as the context menu can be overridden / adjusted based on the collection they're in. For example when using an item directly from the bank it will be stored in the Inventory. When using an item from the inventory while the bank is open, it will be stored in the bank. When using an item while the vendor window is open a sell dialog will be popped.

    Of course this behavior is customizable and can be modified through the editor.


    Vendor system (almost done)
    The vendor system can either generate items or manually define them.

    Also the buy/sell factor can be modified per vendor, by default it's 1, 1.1 would be a 10% increase.
    The close and open animations will be triggered when selecting the vendor, this can be useful to play an animation on a character / the vendor.

    Vendors have a category and buy back can be shared by category. For example when selling to a vendor with the category "Grocer", all other vendors with the same category will have the items available for buy-back.




    Window pages

    Some pages might have tabs or "pages", pages can be defined through the editor.
    Assume you want to make a character window with multiple tabs, pages is what you want to use :). Window pages are backward compatible, so if your windows have no extra pages, just continue as you were.



    Hope you like it and more to come soon :)
     
  9. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    429
    Iwonder if it is easy to integrate GDE into the system?
    I see that it has its own item editor,
    but I have created my items,
    character fields (attributes, str/agi/int), all inside GDE.
     
  10. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,520
    Hey Gekigengar,

    It's a rather specific integration, also porting would be difficult considering I don't know your current data structure. And last but not least if GDE doesn't use pre-processor directives I can't write compiler time code (if people don't have GDE and I write some porting code on it, all people without GDE would get compile errors).

    I'll have a look at it once I'm done with the Vendor and Crafting system, no promises though.
     
  11. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    429
    I was actually asking "How easy?" would it be to use/retrieve the data from GDE into the inventory system, instead of the given editor.

    I am currently writing my own Inventory system for the game, using GDE as its data source.

    But it gets a little bit too complicated, and I don't actually quite understand where to start when creating an inventory system.

    That is why I wanted to purchase this, to customize it to fit my game.
     
  12. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,520
    Hey Gekigengar,

    Items for the InventorySystem are serialized by Unity as prefabs. This means that you can create them directly inside the inspector or from the editors I've created for ease of use.

    If you want to convert the items from the GDE to the InventorySystem you can create a little editor script to create prefabs, attach the associated script and move the variables.

    The following code creates a consumable item and adds it to the InventoryManager. You can set your own variables from GDE, and voila :). Just write a little loop and move all the items.
    Code (CSharp):
    1.  
    2. string prefabPath = EditorPrefs.GetString("InventorySystem_ItemPrefabPath") + "/item_" + System.DateTime.Now.ToFileTimeUtc() + "_PFB.prefab";
    3.  
    4. var obj = GameObject.CreatePrimitive(PrimitiveType.Cube);
    5. var prefab = PrefabUtility.CreatePrefab(prefabPath, obj);
    6. var comp = (InventoryItemBase)prefab.AddComponent(typeof(ConsumableInventoryItem)).GetClass());
    7. comp.ID = (manager.items.Length > 0) ? (uint)manager.items.Length : 0;
    8.  
    9. /// Set your stuff here...
    10. comp.requiredLevel = ....;
    11. /// Set your stuff here...
    12.  
    13. var items = new List<InventoryItemBase>(manager.items);
    14. items.Add(comp);
    15. manager.items = items.ToArray();
    16. Object.DestroyImmediate(obj);
    17.  
     
  13. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,520
    Would anyone be interested in a UFPS integration?
     
Thread Status:
Not open for further replies.