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. darrennorthcott

    darrennorthcott

    Joined:
    Jun 17, 2014
    Posts:
    20
    I tried manually scaling, but because I am supporting native OS/Windows screen size and iPad (retina) the canvas scaler is the only option I can find...
     
  2. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Hello, I've tried a lot of methods to get the correct mouse position while using a canvas scaler but still couldn't determine it exactly as it the dragged UI object gets drifted away every time. The issue has been reported by others (non S-Inventory users) so Unity might drop a fix in the future.

    Could you screenshot your Unity project view so that I can see the issue when the Canvas Scaler isn't active? Maybe we can find another solution without having to use the Canvas Scaler component.
     
  3. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Hello I have a problem with S- Inventory with Realistic FPS Prefabs , I followed the tutorial on a forum but the problem is that when I took the weapon icon turns white in the inventory or when I throw the weapon, the weapon is still in my hand. How to fix this? Thank you
     
  4. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    The white icon appears because you haven't placed the item's sprite in the Resources folder.
    Which tutorial have you followed to get S-Inventory to work with Realistic FPS Prefab? The one I'm aware of requires the Dialogue System as well.
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Ludo97 - Make sure to follow the Dialogue System's setup steps for S-Inventory Support as well as Realistic FPS Prefab + S-Inventory Support. As @SoumiDelRio says, your sprites need to be in Resources. Your item prefabs need to be in Resources, too, and they can't be in subfolders. (This is a requirement of the Dialogue System's S-Inventory support packages.) You can organize your folders like this:

    Item Prefabs/
    Food/
    Resources/​
    Armor/
    Resources/​

    But not like this:

    Resources/
    Item Prefabs/
    Food/
    Armor/​

    Also, the Item name in the Item script must exactly match the name of the GameObject and prefab. And if you're integrating with RFPS's pickup and weapons systems (e.g., for ammo items), remember to follow the extra steps in the RFPS + S-Inventory page linked above.
     
  6. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Hello and thank you , but I still have this white icon problem and also when I go into the inventory and I loose the weapon, the weapon is still in my hand
     
  7. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Hello, please check if you've set the item's sprite in the inspector or not.
    As for the other issue, try to set up the integration again by following the guide posted by @TonyLi above. Maybe you've missed something. And what is the versions of S-Inventory and Realistic FPS Prefab you're using?
     
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Ludo97 - It sounds like S-Inventory is working correctly. It's probably just a setup issue with the RFPS integration scripts. Please feel free to send an example project to tony (at) pixelcrushers.com. I'll be happy to take a look and give you the remaining setup steps.
     
  9. Gaffeth

    Gaffeth

    Joined:
    Jan 29, 2016
    Posts:
    1
    Unity version 5.3.1f1 (64-bit)
    I'm having an issue with S-Inventory. It's not just in my project but in a clean new project as well. All seems to work out the box until I attempt to pick up an item. Picking up anything labeled as currency works but nothing labeled as an item. The issue is that when attempting to pick up an item it crashes the game instance and if running from Unity editor it crashes the editor as well. The demo crashes the same way. Only thing I have not tried yet, but just thought of is reinstalling Unity. Any suggestions would be appreciated.

    ** Update **
    Problem fixed. There was an update to Unity that Unity itself didn't notify me of. Once I updated, everything started working properly.

    Loving the Inventory system. Keep up the good work.
     
    Last edited: Jan 31, 2016
  10. Joker1980

    Joker1980

    Joined:
    Nov 28, 2015
    Posts:
    22
    I own all 3 packages s-spell, s-inventory, and s-quest. All around i love these 3 packages. I have asked the author for a little help in which he didn't respond back. However i was able to do what i was wanting to do through alot of playing around with the coding. I believe that these 3 packages should be usable by them self if you do not wan't to add them into a whole different package. For 1 i am a fan of rpg's. Well today i am sharing a few pieces of code that you are able to use with these packages if you decide to do the same thing. If you own all three packages like i do. If you take and rename spellDamage to EnemyHealth and after you save you will get 1 or 2 errors if you go where you get the errors and change spellDamage to EnemyHealth this will fix those errors. Next in you newly made EnemyHealth script add
    public int XPtoGive = 50;
    into the top along with
    [HideInInspector]
    public ExperienceManager XPManager;
    [HideInInspector]
    Next replace the public void AddHealth function with
    public void AddHealth ( int Points ){
    if(Health+Points > MaxHealth)
    {
    Health = MaxHealth;
    }
    else
    {
    Health += Points;
    }

    if(HPText) HPText.text = Health.ToString()+"/"+MaxHealth.ToString();

    if(Health <= 0)
    {
    Die();
    Destroy (gameObject);
    XPManager.AddXP(XPtoGive);
    //Health = MaxHealth;
    }
    }
    What this does is when you kill the enemy it will destroy the enemy along giving it you the exp that you declared
    in XPtoGive.

    Next in the S-Inventory scripts create a new script called WeaponDamage.
    Below is the coding you will need.
    using UnityEngine;
    using System.Collections;

    public class WeaponDamage : MonoBehaviour {
    public int Damage = 0;

    //[HideInInspector]
    //public SpellDamage WeaponManager;
    // Use this for initialization
    void Start () {
    //WeaponManager = FindObjectOfType(typeof(SpellDamage)) as SpellDamage;
    }

    // Update is called once per frame
    void Update () {

    }
    void OnTriggerEnter (Collider other)
    {
    other.gameObject.GetComponent <EnemyHealth> ().AddHealth (-Damage);
    //WeaponManager.AddHealth (-Damage);
    //WeaponManager.AddHealth (-Damage);

    }
    }
    Now going back to the EnemyHealth script add in
    [HideInInspector]
    public WeaponDamage WeaponManager;
    Now on the item you have on your charecter add the weapon damage script and set the collider to a trigger.
    What this does is when the enemy comes into contact with the weapon it will lose the set amount of health
    that you have set to the weapon.
    Another thing i decided to do as well was inside s-inventory i changed the vendor so that way if i had a item i was selling to the vender i would receive a different price for the item than what he was selling it for. This can be done by going into the item.cs script and adding in
    public int CurrencySellAmount;
    Next open vendor.cs and on line 204
    replace with
    InvManager.RemoveCurrency(SoldScript.Currency, -SoldScript.CurrencySellAmount); //Increase the currency amount!
    Next open vendorUI.cs
    and on line 362 replace it with
    int Price = ActiveVendor.ItemsToSell.gameObject.GetComponent<Item>().CurrencySellAmount*ActiveVendor.ItemsToSell.gameObject.GetComponent<Item>().Amount;
    I hope this helps anyone wanting to do something like what i did as well.
     
  11. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Hello,
    I haven't received any support e-mail from you. It seems like you have wrong contact info.
    Anyway, would you explain more what you want to do with this code modification? Maybe we can find a more efficient way to achieve what you're trying to do or we can add your suggestions to a future update.
     
  12. AMU4u

    AMU4u

    Joined:
    Feb 16, 2015
    Posts:
    14
    This package now has 20+ errors associated with obsolete code lines. Package needs to be updated or removed.
     
  13. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Which version of Unity are you using? I'm not seeing any errors on 5.0.0, 5.1.2 and 5.3.4.
     
  14. AMU4u

    AMU4u

    Joined:
    Feb 16, 2015
    Posts:
    14
    I am using 5.3.4, the errors come from your use of setactive. It's like 22 errors, all you have to do is go through and switch them to activeinheriarchy.


    I am really impressed by this asset. You did such a good job coding it. I am running through the scripts for the last couple days, and you really set up everything nicely and commented really well.
     
    Last edited: Apr 27, 2016
  15. AMU4u

    AMU4u

    Joined:
    Feb 16, 2015
    Posts:
    14
    Question..


    How would you do projectiles in your system? For instance, a pistol. Would you make a seperate script that attached to each weapon that controlled the amount of amount, if it was able to fire, etc?
     
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    That's essentially what the Dialogue System's S-Inventory + Realistic FPS Prefab (RFPS) integration does. When the RFPS player fires a weapon, a script calls S-Inventory's InventoryManager.RemoveItem method to update S-Inventory. When the player picks up ammo using S-Inventory, a script tells RFPS that it now has more ammo. Etc.
     
  17. AMU4u

    AMU4u

    Joined:
    Feb 16, 2015
    Posts:
    14
    Seems rather complicated.

    I was meaning if he would do it inside of the base item script or not. I am going to make a projectile script that just has a for loop that counts the ammo, and checks the status of the projectile. Then a script that handles each type of projectile firing weapon, a base gun script, if you will.

    Plus I am not doing fps :p
     
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Yeah, it's complicated in the RFPS case because it's acting as a middleman for two products that weren't specifically designed to work together.

    In your case, it should be simpler, and you don't even need to touch the base item script. S-Inventory has an InventoryEvents script with events such as PlayerAddedItem and PlayerEquippedItem that you can hook into.
     
  19. AMU4u

    AMU4u

    Joined:
    Feb 16, 2015
    Posts:
    14
    Hi me again!

    How would you implement a gun into your item system?
     
  20. zephyo

    zephyo

    Joined:
    Mar 28, 2016
    Posts:
    33
    Hi, I noticed on your website you said S-inventory has 2D support. I'm making a 2D game; how would I go about adapting the inventory for 2D? My player can't seem to pick up items as it is currently.
     
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    If you've set the Inventory Manager's Pickup Type to Mouse, S-Inventory does a 3D distance check from the player to the item. This takes into account the Z-axis distance (i.e., depth). Keep this in mind when setting the item's Min Distance value.

    If you've set Pickup Type to Keyboard, it looks like there might be a bug or omission in Item.cs. To fix it, make a copy of the OnTriggerStay method, which starts around line 94. Change the name of the method to OnTriggerStay2D, and change all instances of the word "Collider" with "Collider2D" (there are 3 instances) in the method.
     
  22. zephyo

    zephyo

    Joined:
    Mar 28, 2016
    Posts:
    33
    Hi TonyLi again! That item.cs fix really did the trick, thank you so much!
     
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Happy to help!
     
  24. zephyo

    zephyo

    Joined:
    Mar 28, 2016
    Posts:
    33
    Hi again, I have another issue with the inventory. All sound effects fail to play. I have Audio Source on InventoryManagerC# enabled. I would really appreciate any help!
     
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Do you perhaps have two Audio Sources on InventoryManagerC#, one of which is disabled?

    If there's only one, check these things:
    • Enabled
    • Output is unassigned, or assigned to a Mixer Group that's audible
    • Mute is not ticked
    • Volume is not 0
    • Spatial Blend - try sliding it all the way to the left (2D)
     
  26. zephyo

    zephyo

    Joined:
    Mar 28, 2016
    Posts:
    33
    Oh wow it was the spatial blend that was messing it up! Thank you again, Li!! :D
     
  27. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    You're welcome! :)
     
  28. zephyo

    zephyo

    Joined:
    Mar 28, 2016
    Posts:
    33
    Hi, it's me again, sorry I have so many troubles. Hopefully this will be the last of them. After I replaced the audio, the ItemInfo doesn't enable on hover anymore. Also, after dragging the item, it doesn't drop back into its slot.

    I get errors in the console:
    NullReferenceException: Object reference not set to an instance of an object
    SlotUI.RemoveDragDestination () (at Assets/S-Inventory/C#/Scripts/Item/SlotUI.cs:405)

    For cs: lines 277, 371, and 405
    Using S-Inventory v. 1.25

    InvContainer.DraggingItem can't seem to find my item but I'm not knowledgeable enough to know how to fix it. I hope someone can help me again.
     
  29. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @zephyo - Can you try updating to the latest S-Inventory (1.30)? The release notes for 1.27 say that it fixed a bug when dragging items. Maybe the update will fix the issues.
     
  30. zephyo

    zephyo

    Joined:
    Mar 28, 2016
    Posts:
    33
    Hi TonyLi, I updated, but it still isn't fixed. :/ The error has just changed to cs lines 283, 380, 418.
     
  31. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    I think your player's S-InventoryC# is missing a ContainerC# GameObject, or the GameObject is inactive.

    Compare your scene to one of the example scenes. For example, open Dialogue System/Third Party Support/S-Inventory/Example/S-Inventory Example. Expand S-InventoryC# > S-InventoryC# and look for ContainerC#. This GameObject should be active, and it should have a "Container UI" component.

    p.s. - Remember to make the change to Item.cs again since you updated your S-Inventory version.
     
  32. zephyo

    zephyo

    Joined:
    Mar 28, 2016
    Posts:
    33
    I activated the Container C# and nothing changed, but I noticed the prefab inventoryC# worked fine, so I just started over with replacing the GUI and doing my custom tweaks. Thank you for your help once again, I should be good to go now.
     
    TonyLi likes this.
  33. goldencruz

    goldencruz

    Joined:
    Oct 2, 2013
    Posts:
    94
    so I think I manage to get the inventory to work with invector character controller but since character controller use left click to attack and right to block it conflicts. Is there a way if the inventory comes up to pause the game or at least disable the player actions this way you can use the inventory then when done it goes back to normal
     
  34. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    What exactly do you need to make those assets work together?
    Please note that you can always use the S-Inventory and S-Quest custom events: Any major action that happens in those two assets will trigger a custom event which will allow you to link your Third Person Controller and S-Inventory/S-Quest.
     
  35. AMU4u

    AMU4u

    Joined:
    Feb 16, 2015
    Posts:
    14
    In the sample scene provided in the new upload, where do you place the s-inventory prefab exactly? I don't see where you put the scripts for the example scene...
     
  36. peteoaten

    peteoaten

    Joined:
    May 17, 2016
    Posts:
    10
    Hello,

    Nice asset, set it up in a 2D game im messing around with.

    I have a probable simple problem. My mouse will not interact with the inventory in any way shape or form. I can not click the X to close it. I can not click the Tabs. I can put an item in the inventory via mouse click, but once there can not interact with the item in the inventory.

    Im sure its a simple thing, but i have read the whole thread here and can not see an answer.

    Many thanks
     
  37. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    See this post for a fix.
     
  38. peteoaten

    peteoaten

    Joined:
    May 17, 2016
    Posts:
    10
    Yeah thanks, i read that post, however, i have changed the script and can pick items up and they go into the inventory, my problem is i can not interact with the inventory screen once items are in there. I cant click on the tabs or the X either. It seems the inventory is not recognising the mouse
     
  39. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Does your scene have an Event System? (GameObject > UI > Event System)
     
  40. peteoaten

    peteoaten

    Joined:
    May 17, 2016
    Posts:
    10
    Does your scene have an Event System? (GameObject > UI > Event System)

    Duh, :D
     
  41. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    I do that all the time. That's why the Dialogue System automatically adds an EventSystem at runtime if you're missing one and you're using Unity UI.
     
  42. peteoaten

    peteoaten

    Joined:
    May 17, 2016
    Posts:
    10
    Hi TonyLi,

    Me again. Got most things set up and working just great. I do have one issue i wonder if there is a solution for.

    As i am using 2D is there some code i can change to have the item dropped away from the player? As it stands at the moment the item drops right back onto the player obj and is instantly picked up. This causes problems with equipping the item to the player obj also as its constantly put back into the inventory if i equip to the player.

    Adjusting the drop distance in the Inventory Manager makes no difference, but i realise its probably set up for 3D.

    All works fine if i set to mouse click pickup.
     
  43. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    If I can get a chance today, I'll take a quick look. Otherwise it sounds like something @SoumiDelRio should be able to answer.
     
    OussamaB likes this.
  44. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Hello,

    I've changed the drop distance float variable to a vector 3 so you can choose the drop distance on all axis, not only the z axis. This way you have more flexibility on where you want the item to dropped.

    You just need to open the "InventoryManager.cs" script and look for the line below:
    "public float DropDistance = 0.5f"
    And replace it with this line:
    "public Vector3 DropDistance = new Vector3();"

    Then look for this line, in the same script:
    "CloneItem.transform.localPosition = Player.transform.position + Player.transform.forward * DropDistance;"
    And replace it with this:
    "CloneItem.transform.localPosition = new Vector3 (Player.transform.position.x+DropDistance.x, Player.transform.position.y+DropDistance.y,Player.transform.position.z+DropDistance.z);"

    And this should fix your problem.

    If you can't make the changes yourself, please PM me your e-mail address and invoice number and I'll be more than happy to send you the modified version of the script.
     
    TonyLi likes this.
  45. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    In the demo scene, the S-Inventory prefab (which includes most of the managing scripts) is located as a child object of the "Player" object.
     
  46. peteoaten

    peteoaten

    Joined:
    May 17, 2016
    Posts:
    10
    Thanks, for the above. Solved and working great. !
     
  47. Idialot

    Idialot

    Joined:
    Dec 8, 2013
    Posts:
    18
    Anyone know of help with S-Inventory and RFPSP without the dialogue system as don't need it.
     
  48. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Good luck with that.
     
  49. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Feel free to pull what you can from the Dialogue System's RFPS and S-Inventory support packages. It was fairly complicated to get them working together. You'll need to comment out or remove all the Dialogue System-specific stuff. Or, if you want to be able to save and load games or do quests/missions, please keep the Dialogue System in mind.

    SInventory_Support_2016-02-29.unitypackage
    RFPS_Support_2016-04-30.unitypackage
     
  50. Idialot

    Idialot

    Joined:
    Dec 8, 2013
    Posts:
    18
    Thanks Tony.... Ill import the files and check them out. Quite sure I can figure things out from here. Thanks again... Cheers.
     
Thread Status:
Not open for further replies.