Search Unity

S-Inventory: Equipment, Crafting, Skill Bar, Item Groups, Containers & Merchant (C# & JS)

Discussion in 'Assets and Asset Store' started by OussamaB, Jul 29, 2013.

Thread Status:
Not open for further replies.
  1. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    What you need to do is to call these two functions from the "InventoryManager" script: "LoadItems();" and "SaveItems();". However, items are automatically saved and loaded so if you'd like to disable the automatic saving and loading, just uncheck the "Save And Load" option from the inspector and call the functions above in your code to save and load items.
     
  2. ahaykal

    ahaykal

    Joined:
    Apr 18, 2010
    Posts:
    117
    Hello,

    I have tried importing the asset into a new project but to no avail. Unfortunately I don't have an older version of unity but I can try. Which version should work ? Screenshot attached.

    Thanks
     

    Attached Files:

  3. BuckeyeStudios

    BuckeyeStudios

    Joined:
    Oct 24, 2013
    Posts:
    104
    has anyone got this working with UnitZ from the asset store and if not and i bought this would anyone want to help
     
  4. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Try to test it with 4.6.1 since it's the version I submitted the asset with. I'm downloading 4.6.3 to test the asset on it and see if it works for me.
     
  5. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Please send me a link of the asset in a PM and I'll see if I can help to link it with S-Inventory.
     
  6. Uto

    Uto

    Joined:
    Nov 10, 2014
    Posts:
    17
    Hello!
    I also have trouble with 4.6.3: items in bag are not showing. In 4.6.1 it works.
     
  7. ahaykal

    ahaykal

    Joined:
    Apr 18, 2010
    Posts:
    117
    Hello Soumi,

    I was just messing around with it and found out that when I press play the inventory slot becomes null. I hope this might help you with debugging or anything.
     
    Last edited: Feb 25, 2015
  8. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Thanks for your help. The problem is due to Unity 4.6.3, if you can, please use an older version (4.6.2 or 4.6.1) till I fix this bug.
     
  9. Uto

    Uto

    Joined:
    Nov 10, 2014
    Posts:
    17
    Website is down again. Could it be possible to include pdf manual with the asset?
     
  10. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Sorry for that, it seems that the whole host is down. The reason I didn't include a pdf manual with the asset is because I'm constantly modifying the documentation. It will be up again shortly. Meanwhile, please try this solution:

     
  11. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    soumidelrio.com is working since few hours. The problem has been fixed and you can access the documentation again.
     
  12. Uto

    Uto

    Joined:
    Nov 10, 2014
    Posts:
    17
    Hi!
    There seems to be a bug when looting item group when inventory/riches is open -> no items are looted. This happens with both C# and JS demos also.

    Also, could it be possible to get more events, for example when item groups are opened, items looted etc?
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,702
    +1. The events you've already added are very helpful, and more would be great, such as when you open and close a vendor.
     
  14. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    I can not reproduce the bug you've described, it's working correctly here. Anyone else having this problem?

    More events it is! Thanks for the suggestion.
     
  15. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,702
    I can reproduce it. Here are the steps I used:
    1. Play S-Inventory/Demo/SceneC.
    2. Walk to the item group so I see "Press E to open the item group".
    3. Press "I" to open the inventory window.
    4. Click on the "Riches" button to show riches.
    5. Press "E" to open the item group.
    6. Click "Take All".
    It adds the Gold, but it doesn't add the Axe and Shield.
     
  16. ahaykal

    ahaykal

    Joined:
    Apr 18, 2010
    Posts:
    117
    Hello Tony,
    It might be because you are using Unity 4.6.3, because I am facing the same problem and the bug will be fixed soon :)
     
  17. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    It seems that changing the parent object in 4.6.3 of the slot is making its scale set to 0,0,0 which is why the slot isn't appearing on the inventory and container panels. It has been fixed and the update will be submitted later on today as I need to make sure that everything else related to changing the parent object is working correctly.

    Thanks, I was able to reproduce the bug. The inventory UI panel wasn't refreshing when the items were added from the item group and the riches is open.
     
  18. Uto

    Uto

    Joined:
    Nov 10, 2014
    Posts:
    17
    Using spawn item setting: If I pick a single item from the ground and drop it, it spawns to it's original position(where it was picked from) I cannot pick it again. But if I pick an item from item container, everything works fine. I just cannot figure it out where the problem is...

    Edit: I found the cause, when item is re-spawned, only the collider spawned to the correct position, mesh stays where it was originally.
     
    Last edited: Mar 1, 2015
  19. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Have you made any code modification? Because it's working correctly here.
    Anybody else having this problem?
     
  20. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Hello guys! For some unknown reason, I can not update the asset as the asset store publisher tools aren't working for me. If you'd like to get the new features (equipment attributes), the 4.6.3 UI fix and the Unity 5 version then please PM me your e-mail and invoice number while I'm working to find a solution to upload the update.

    EDIT: I got it working and the update has been submitted.
     
    Last edited: Mar 6, 2015
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,702
    I just added persistent data components for vendors and item groups to the Dialogue System for Unity's support package for S-Inventory support. This allows them to remember their contents in saved games and level changes. You can download it here: SInventory_Support_2015-03-12.unitypackage [EDIT: Added persistent data component for item pickups, too.]
     
    Last edited: Mar 13, 2015
    OussamaB likes this.
  22. vincentellis

    vincentellis

    Joined:
    Oct 21, 2013
    Posts:
    100
    Is this compatible with the Realistic FPS Prefab? If so, where's the integration tutorial?
     
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,702
    It depends on what you mean by compatible. With scripting, you can make it work. If you don't want to work out the scripting, the Dialogue System for Unity has drop-in, script-free support packages for S-Inventory and RFPS. There's no video tutorial yet, but there's text:
    If you don't want to use the Dialogue System, you can glean some ideas of how to do it from the documentation and use it to write your own integration.
     
  24. vincentellis

    vincentellis

    Joined:
    Oct 21, 2013
    Posts:
    100
    Problem is: i don't want the Dialogue system, just the S-Inventory integrated with RFPS. :rolleyes:
     
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,702
    You're welcome to grab the source code from the link in this post. It uses the Dialogue System so it won't compile out of the box without it, but you can yank that out and replace it with your own functionality. The reason why it uses the Dialogue System is because the Dialogue System provides a Lua environment that can hold all the data to exchange between all of the products. (And also to make it available to the Dialogue System's save/load system, quests, conversation, etc.) But there's a lot of useful information in there that's unrelated to the Lua environment, such as how and when to show and hide the cursor to make it work correctly with RFPS and S-Inventory.
     
  26. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    I updated the demo web player to show you how it works on Unity 5 and how equipment attributes work and added a new menu to change the inventory settings to test few hidden features of the asset.

    http://soumidelrio.com/asset/s-inventory/demo.html
     
  27. Uto

    Uto

    Joined:
    Nov 10, 2014
    Posts:
    17
    Picking gold does not seem to add amount of gold in inventory in web demo?
     
  28. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Thanks for reporting that bug, it has been fixed.
     
  29. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    I've submitted another update to fix the currency UI refresh bug and few other small bugs.
     
  30. JasonSNZ

    JasonSNZ

    Joined:
    Jan 26, 2015
    Posts:
    3
    Hi, just picked up your inventory system and overall I'm pretty happy with it. Here are a few things I think are enhancement requests (and reasons why I need them so you understand context). I'm new to the tool, so maybe there are other ways to accomplish what I'm looking for here that I've missed.

    1. Option to destroy or spawn an item when dropped from inventory should be over-ridable or purely driven from the Item class. For example, I have wood in my inventory and want to add it to my fire. I use the wood and it should disappear from my inventory and the world. However, I may also want to just remove it from my inventory for awhile. I don't want it to be destroyed on drop. I'm not sure yet what I need to do to make this work on my own.

    2. When I use an item in inventory, I need to have the removal from inventory be based on whether the use was successful or not. For example, again I have wood in my inventory. I want to build a house with it, by "using" it in a specific spot in my world. When I build the house to completion, any further attempt to "use" the wood should fail and the item should not be removed from my inventory. In my fire example above, I limit how big of a fire can be created (basically a health system for the fire), and when I reach the max, any attempt to add more wood to the fire will fail.

    I've made this change myself by adding a new delegate ItemEventHandler that returns a boolean. My "onPlayerUseInventoryItem" script also returns the boolean so the call to it in SetActionType checks the result and only removes the item if the event returns true. I've not made ALL of the changes in the system to handle this yet.

    3. This is related to the above example. Instead of passing the ItemScript.name through to onPlayerUseInventoryItem, I pass the actual ItemScript object. I need the actual item passed through because in my delegate methods that act upon the use, I need to inspect the object's attributes. For example, my wood objects come in two sizes, big and small. A big bundle will have more "burn" value than a small one. The burn value is an attribute of the Item. Adding a bigger bundle adds more to the fire than a small bundle. Again, I've made the changes in my own script to handle this, but only in the one instance where I've needed it.

    4. This is related to #1, I was experimenting with using the crafting system to build my houses as an alternative to the current method I'm using which is to use OnTriggerEnter/Exit on my house building locations to add/remove delegate function to event system when I use an inventory item. Using the crafting system, I can build the house with a recipe and it appears in my inventory, but with the drop behaviour set to destroy (again to support my adding wood to the fire example), the house is destroyed. This is another example why I can't have the drop behaviour be a global setting.

    5. Out of the box 2D support. This was pretty easy, I just had to change all of the collider and trigger references to the 2D versions. So far it seems to work, but it would be nice to have support for 2D without having to patch in the changes every time you do a release. I also changed the defaultItem to have 2D collider and sprite renderer.

    Like I said, overall I'm quite happy with the system, it's saved me heaps of time and I've learned some stuff about Unity as well.

    Code for the changes (except for 2D support changes) is below:

    InventoryEvents.cs
    // Delegate for inventory events:
    public delegate void ItemEventHandler(string itemName);

    public delegate bool bItemEventHandler(Item itemObject);
    public event bItemEventHandler bPlayerUsedInventoryItem = delegate { return false; };


    public bool OnPlayerUseInventoryItem(Item itemObject) {
    if (debug) Debug.Log("Just used itemObject " + itemObject.Name + " from the inventory");
    return bPlayerUsedInventoryItem(itemObject);
    }


    InventoryUI.cs (SetActionType function)
    else if(ItemScript.Usable == true)
    {
    //CustomEvents.OnPlayerUseInventoryItem(ItemScript.Name);
    if (CustomEvents.OnPlayerUseInventoryItem(ItemScript)) {
    Debug.Log("success use of " + ItemScript.Name + " removing");
    InvManager.RemoveItem(InvManager.Slots[ActionID].Item, 1);
    }
    else {
    Debug.Log("failed use of " + ItemScript.Name);
    }

    }
     
  31. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    1) About the item drop issue, how about to have an option in the item class whether to use the global drop variable (which most of your items will be using) or a specific drop type (destroy or spawn). I think that solves the problem so that houses can be spawned into the real world and wood can be destroyed at the same time.

    2) And for removing items from the inventory on use. I can't think of a dynamic way to support having successful or failed use of the item however I can add an option to whether destroy or not to destroy all items on use and then in the custom item use event, you can check if the wood item has been used in a proper position and destroy it. And if you want to destroy all other items on use, you can check if they're not a wood item in the OnPlayerUseInventoryItem event and destroy them even with having the global destroy on use variable set to false.

    3) I totally agree that passing the whole item class in the inventory event will be way more useful than passing the name and the amount only. It will be added in the next update.

    4) The 2D support is also very useful, thanks for the suggestion.

    If 1) and 2) will help you accomplish what you need, please let me know and I'll add them. Please PM me your e-mail and invoice number as well so you don't have to wait for the update to hit the asset store and continue your project ASAP.
     
  32. JasonSNZ

    JasonSNZ

    Joined:
    Jan 26, 2015
    Posts:
    3
    Thanks for the quick reply. Here are my responses:

    1) Yes that is what I meant by "over-ridable". Give us the option to decide on a per item basis whether to destroy on drop and destroy on use. Perhaps defaultItem has "useGlobalDropType" as an option, as well as "onUseDestroy" and "onDropDestroy" options.


    2) What about having every "use" call always return a boolean to start with. Then within SetActionType or RemoveItem, you can check for a configured option. See below for doing it in SetActionType, where I assume CheckUseStatus is configured via the Inspector per Item. I think the code below will retain the default behaviour you have now, where the item is always used regardless of status returned from OnPlayUseInventoryItem, but also if configured to check the status.

    //Pass Item object to OnPlayerUseInventoryItem
    //get the return status
    bool status = CustomEvents.OnPlayerUseInventoryItem(ItemScript);

    //Override the returned status from above if the Item isn't configured to be checked //for use status
    status = ItemScript.checkUseStatus ? true : status;

    if (status) {
    Debug.Log("Success use of " + ItemScript.Name + " removing");
    InvManager.RemoveItem(InvManager.Slots[ActionID].Item, 1);

    }
    else {
    Debug.Log("Failed use of " + ItemScript.Name);
    }

    Ultimately I think you offer the most flexibility in the system if you can make as many of the behaviour decisions made by the Item instead of globally.

    I will PM you my details, but I hope you find the above as a viable option for meeting my requirements as well as providing the dynamic configuration of the system behaviour that you require.



     
  33. ZodiaXCorpX

    ZodiaXCorpX

    Joined:
    Sep 16, 2014
    Posts:
    5
    Hello i have ran into a problem with the 5.0 update to unity. I am in Android build and i have this error here

    Assets/S-Inventory/JS/Scripts/Item Group/ItemGroupUI.js(114,103): BCE0019: 'ItemType' is not a member of 'UnityEngine.Component'.
    Assets/S-Inventory/JS/Scripts/Item Group/ItemGroupUI.js(150,96): BCE0019: 'ItemType' is not a member of 'UnityEngine.Component'.
    Assets/S-Inventory/JS/Scripts/Inventory/InventoryManager.js(452,80): BCE0019: 'Name' is not a member of 'UnityEngine.Component'.
    Assets/S-Inventory/JS/Scripts/Inventory/InventoryManager.js(522,80): BCE0019: 'Name' is not a member of 'UnityEngine.Component'.

    I would really appreciate your help on this Thank you.
     
  34. ZodiaXCorpX

    ZodiaXCorpX

    Joined:
    Sep 16, 2014
    Posts:
    5
    I have found a work around to this, Just delete the JS Version of this.
     
  35. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Here's the features list of the next update:

    - 2D support.
    - Added an option to use the global drop type or pick a different drop type for each item.
    - Added an option to disable/enable showing toggle info for each UI panel.
    - Added 12 events for showing/hiding UI panels.
    - Added the option to destroy or keep items on inventory use.
    - The whole item object is now passed in the inventory events for more customization.

    I'm currently updating the documentation and will submit the update later today.

    I've added the option to destroy the item on use or keep it in the inventory. For your wood example, you could set every wood object to stay in the inventory on use and in the OnPlayerUseInventoryItem event, check for the use position and remove from the inventory manually if it was used in the correct position.
     
  36. JasonSNZ

    JasonSNZ

    Joined:
    Jan 26, 2015
    Posts:
    3
    Thanks Soumi, sounds like you've adopted most of my changes. That will make integration easier. I look forward to the next release.
     
  37. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    I just sent you the update via e-mail. Thanks again for the suggestions!
     
  38. sheffieldlad

    sheffieldlad

    Joined:
    Oct 9, 2013
    Posts:
    154
    Hi,

    I'm using Unity 4.6.3 and waiting for the bug fix for the items not showing in the inventory.

    When I look on the asset store it says 'Needs an upgrade to Unity 5'

    Does that mean support for 6 is finished?
    Is the 4.6.3 bug fix still on its way?
     
  39. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,702
    Is it possible to make a 4.6.3 package for the new update? A lot of users are working on projects that are platform-locked on 4.x.
     
    sheffieldlad likes this.
  40. sheffieldlad

    sheffieldlad

    Joined:
    Oct 9, 2013
    Posts:
    154
    for anyone who 's interested, I got slots showing by setting the scale of them after they are parented to the panel.

    add this:

    Code (CSharp):
    1. Slot.transform.localScale = new Vector3(1,1,1);
    after this
    Code (CSharp):
    1. Slot.transform.SetParent(Panel.transform, true);
    at around line 193 of InventoryUI.cs
    I don't know the 4.6.x UI system very well yet and I haven't made any items for s-inventory so I don't know if the actual items will show. It may be that they also need to be scaled after they are parented.

    I will look tomorrow and post back. It's past my bedtime now :)
     
  41. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    You can download the project in Unity 5 (you can install it along with 4.6.3) and then export it and import it into your 4.6.3 project. If you don't have Unity 5, please PM me your e-mail and invoice and I will send you the asset. I think I'm going to downgrade the Unity version needed for S-Inventory since the Unity 5 version is working on Unity 4.6.3.
     
    TonyLi likes this.
  42. sheffieldlad

    sheffieldlad

    Joined:
    Oct 9, 2013
    Posts:
    154
    PM sent, Many thanks.
     
    OussamaB likes this.
  43. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    I've submitted an update to the asset to make it support 4.6.3 and all superior versions.
     
    sheffieldlad likes this.
  44. ActiveRigStudios

    ActiveRigStudios

    Joined:
    Mar 7, 2015
    Posts:
    9
    Does the vendor system support actual purchases as microtransactions?

    Thanks
     
  45. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Not really, it's designed to allow the player sell/buy S-Inventory items with game currency. But with some code modification, it shouldn't be hard to add micro transactions.


    S-Inventory now supports Unity 4.6.3 and all superior versions including Unity 5.
     
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,702
    Dialogue System users will need to import the updated S-Inventory support package for S-Inventory v1.23. You can download it on the Pixel Crushers customer download site or right here.
     
    OussamaB likes this.
  47. Quanny

    Quanny

    Joined:
    Apr 7, 2013
    Posts:
    14
    I also got this, except only the errors for ItemGroupUI.js, i did not get the errors for InventoryManager.js
    I fixed it by removing the quotation marks inside of the GetComponent("Item") and seemed to fix it..
     
    OussamaB likes this.
  48. HelixU4

    HelixU4

    Joined:
    Jan 25, 2013
    Posts:
    61
    I have a few suggestion to an already awesome package!

    1. Have "esc" button close all open windows. If you have inventory and crafting open, the player can simply hit esc and the windows will close. Maybe adding the ability to customize what button to use to close all open windows.

    2. When selling multiple of the same items you can type in the amount you want to sell. Make it able to just hit the "enter" key to confirm, instead of having to click the button.

    3. Make the item description box resize according to the amount of text. Or make it easy to resize it. Some items might have a long and detailed description with stats and usages etc. The current box is very small and can only hold very short text.
     
  49. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,702
    I second those suggestions. They would be great enhancements to S-Inventory. For #1, can you let the developer set a KeyCode and a button name? In other words, check:
    Code (csharp):
    1. public KeyCode closeAllKey = KeyCode.Escape;
    2. public string closeAllButtonName = string.Empty;
    3.  
    4. var closeAll = Input.GetKeyDown(closeAllKey) ||
    5.     (!string.IsNullOrEmpty(closeAllButtonName) && Input.GetButtonDown(closeAllButtonName));
    6. if (closeAll) {
    7.     // Close all windows.
    8. }
    This will allow "close all windows" to work with gamepads, too.
     
    HelixU4 likes this.
  50. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    All of these suggestions will be added in the next update. Thanks!
     
Thread Status:
Not open for further replies.