Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Official Inventory System

Discussion in 'Open Projects' started by JakHussain, Sep 30, 2020.

  1. CireSur

    CireSur

    Joined:
    Dec 1, 2017
    Posts:
    2
    The add method allows you to add child classes.
    Code (CSharp):
    1.  
    2. Item item = new Item();
    3. ItemVariant itemVariant = new ItemVariant();
    4. Dictionary<Item, int> items = new Dictionary<Item, int>();
    5.  
    6. items.Add(item, 1);
    7. items.Add(itemVariant, 1);
    8.  
    Code (CSharp):
    1.  
    2. public class Item {}
    3. public class ItemVariant : Item {}
    4.  
     
  2. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    Interface works too:

    Code (CSharp):
    1. interface Pickable { }
    2. public class Item1 : Pickable {}
    3. public class Item2 : Pickable { }
    4.  
    5. Dictionary<Pickable, int> ItemList = new Dictionary<Pickable, int>();
    6. //Or
    7. List<Pickable> items = new List<Pickable>();
    8.  
    9. void Start()
    10.         {
    11.             items.Add(new Item1());
    12.             items.Add(new Item2());
    13.  
    14.             Debug.Log(items[0] + " : " + items[1]); //output Item1 : Item2
    15.  
    16.             ItemList.Add(items[0], 3);
    17.             ItemList.Add(items[1], 5);
    18.  
    19.             Debug.Log(ItemList[items[0]] + " : " + ItemList[items[1]]); //output 3 : 5
    20.         }
    21.  
     
    nhatnhiemmo and kirbygc00 like this.
  3. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
  4. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    446
    And that's a good thing. It's like a singleton but it is injected using inspector. The only downside is that after exiting play mode in editor SO will remain runtime values. But that could be solved.
    Ummm... No:) I'm suggesting this because I use this approach in my games. There is no problem to make multiple saves at all.

    Anyway, this approach is not widely used, so ok. Make it singleton MonoBehaviour and everyone will be happy
     
  5. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    236
    For what? We may have inventory for enemies as well
     
  6. DaSerialGenius

    DaSerialGenius

    Joined:
    Jun 27, 2017
    Posts:
    17
    Hey, pardon my inexperience, but what's that lambda thing you've used for a property?

    Also, it seems that I am a bit late to the party :p Time zone difference messed me up. So here's what I was thinking, this is how we would store them and I think it's a good enough implementation. The specific ingredients would come later when the Designers give us the details. I think we should also work on like how we would display it and things like that, so we can have like a Knapsack thing going on if that's something we want. Thoughts?
     
  7. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    236
    Property getter shortcut
     
    DaSerialGenius likes this.
  8. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    236
    We need to have very basic UI at first, nothing fancy.
    I have an idea of making 3D animated knapsack later on :)
     
  9. DaSerialGenius

    DaSerialGenius

    Joined:
    Jun 27, 2017
    Posts:
    17
    oooo that sounds fascinating! Mind if I work with you on that one?
    I guess the biggest question would be how would you rotate an array around 3 axes rather than just the 1 in a 2D array and then check if the sack is full :confused:
     
  10. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    236
    Why would you do that? :)
    Rotation is only for visuals, not array itself
     
  11. DaSerialGenius

    DaSerialGenius

    Joined:
    Jun 27, 2017
    Posts:
    17
    Well the way things are arranged would change right? like in Tetris to some extent, you'd have weirdly shaped items like IDK a leek or something, and then we could rotate it and place it differently. Kinda like in Deus Ex but with less weaponry and more food (which I've been harping on about almost as much as I have been about Interfaces :D)

    upload_2020-10-2_9-38-51.png
     
  12. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    236
    I think we don't need such complex inventory for this project, as we're making something more like "A Hat In Time", rather that "Breath Of The Wild"
    I'm imagining that Items Wheel would fit well
     
  13. DaSerialGenius

    DaSerialGenius

    Joined:
    Jun 27, 2017
    Posts:
    17
    You mean like when you select the hats and stuff? That would be a pretty nice implementation, maybe something where we mix the two and have it be like when youu press the inventory button, and then its the wheel and the pig in the middle. Then when you select an item, the pig is holding it and you can maybe stack them together and come up with a a recipe
     
    Neonage likes this.
  14. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    236
    That's a great idea! :)
     
    DaSerialGenius likes this.
  15. kenkm963

    kenkm963

    Joined:
    Feb 18, 2018
    Posts:
    1
    Hey, sounds like you have a good start on the project. I'd love to help in any way I can. Here's the fork I made from Unity's version. I'm not really too familiar with working with GitHub on large projects, so I wasn't sure if I should fork from your version. What I ended up doing was copying your changes and working from there. Here's my version: https://github.com/knnth3/open-project-1/tree/inventory-system-base

    I went ahead and made a base pickup prefab so we could have something to test with. To add some visual effects, I made a hover & rotate mono-script you could add :)

    In this case I also think an abstract class would be easiest. Maybe when it's time to move onto effects then interfaces could be used there since the scope is a bit larger. It's definitely doable in both ways though
     
  16. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,083
    What about Game Foundation? I know it's still in preview but who knows. Are there any plans to release the package in the near future @erika_d @mingz-unity ? Will there be any breaking changes? This project could be good to verify and validate how useful it is. Would also be interesting proof of concept and example of real project using it.

    As it will be released on Steam it could be used by GF team to expand their store integrations (well also by Unity IAP and ChilliConnect, sidenote: competitor PlayFab already has Steam IAP integration).
     
    tmcdonald likes this.
  17. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    Sounds like a good idea, I'd totally be down for it if we can get permission to add the package.
     
  18. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    Will be interested to get some official feedback or go-ahead in this thread (even though I know y'all are busy!)
     
    SideSwipe9th likes this.
  19. SideSwipe9th

    SideSwipe9th

    Joined:
    Jan 10, 2019
    Posts:
    46
    @tmcdonald I'll try and get a chance to look at the code in your fork tomorrow. Given how detailed all the discussion here has been though I suspect it'll be fine, and we'll just need to see what the Unity guys think.
     
    tmcdonald likes this.
  20. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    It's pretty benign, just based on what we've discussed in this thread (I didn't add anything that we hadn't agreed on as a group.) Given the fact that we haven't had an official response yet, I suspect that they might have other plans for this system. I enjoyed the discussion nonetheless.
     
  21. DaSerialGenius

    DaSerialGenius

    Joined:
    Jun 27, 2017
    Posts:
    17
    Yeah I enjoyed it too! But now I am kinda curious how much influence we have on the overall design of the game. I guess theres nothing we can do but wait for some word from the devs :p

    Btw, pardon my lack of experience, but how would we work together if were to do so?
     
  22. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    236
    Someone makes initial PR in Inventory branch, we clone it and commit changes until it's good to push into master/separate branch
     
  23. ThePineappleDev

    ThePineappleDev

    Joined:
    Mar 26, 2015
    Posts:
    8
    I expect that, given that theyre doing this as employees, the main lack of official response is because it's weekend.
     
  24. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    The first branch and request for feedback was on Thursday. Additionally, there have been several instances of official feedback and discussion in other threads since it was posted here.
     
    lmbarns likes this.
  25. SideSwipe9th

    SideSwipe9th

    Joined:
    Jan 10, 2019
    Posts:
    46
    @tmcdonald had a look through there. Looks good as a base to start from. Hopefully we'll get some feedback on this from the Unity guys this week, though they might want us to make a pull request first? Not sure. From looking at the other threads I get the feeling the Unity guys are a bit overwhelmed with so many people showing interest, plus the initial teething issues with organising a group of this size and geographical distribution.
     
  26. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    Oh yeah, I didn't mean for it to come off as disparaging at all. Actually, my thoughts were more akin to, "This might be a topic that they had intended on having a YouTuber do a video or series on, and so they're not really addressing it." Similar to what happened with Dapper Dino and the bug he fixed in his video.
     
  27. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    I apologize @kenkm963 for not giving you feedback earlier. So, ItemInstance is already essentially the "BasePickup." And I'm hesitant on adding anything that establishes look and feel for now, since those aspects are not designed nor are they part of the card. I know it's frustrating but I think that keeping the scope limited to the defined work will help prevent confusion about what has been added.

    As for contributing, you should be able to fork off of our working branch and submit a pull request to it.
     
  28. cristiancgph

    cristiancgph

    Joined:
    Aug 9, 2018
    Posts:
    2
    Who is contributing to this feature? I would like to help. Thanks in advance.
     
  29. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    Several people, it might be worth reviewing the thread. They had to merge several ongoing disparate threads about the issue, the collective design discussion began roughly here: https://forum.unity.com/threads/inventory-system.980646/#post-6370485
     
  30. cristiancgph

    cristiancgph

    Joined:
    Aug 9, 2018
    Posts:
    2
    Thank you for your prompt reply. I understand that your branch is the one involved in this task. Can the code be reviewed and improved?
     
  31. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    236
    You don't have to ask, just do if you feel like it :)
     
    MileyUnity and cristiancgph like this.
  32. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    Sure, and there is no guarantee that my PR will be what goes forward. Ideally, since I use source control at my job and do this kind of thing all the time, I'm hoping once we get the go-ahead, I might be able to work with someone who has never contributed to source control and help them actually submit the PR.
     
  33. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    884
    Hey @tmcdonald, sorry for the delay! I missed the latest updates on the thread because it fell on earlier pages.

    But what should I give feedback on? Sorry the thread is mega-long. I also see that you already closed the PR you made on Github.

    ... Anticipating one potential answer, if the question is whether we want to use Game Foundation for the inventory, the answer is no: this is not a F2P game, and Game Foundation is waaaaay beyond the scope of what we're doing here.
     
  34. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    I had an earlier PR that did not incorporate the teamwork process and thought it was in poor taste given the collaborative nature of the exercise, so I closed it before it got reviewed. I can create this PR for now, which will be very preliminary, definite room for adding features. We went very barebones and simple-to-expand.

    EDIT: It might take a minute, I need to incorporate the coding standards.

    EDIT 2: https://github.com/UnityTechnologies/open-project-1/pull/100 the PR is available.
     
    Last edited: Oct 21, 2020
    MUGIK likes this.
  35. Soundguy

    Soundguy

    Joined:
    Oct 30, 2009
    Posts:
    48
    I want to make an argument in favor of Prefab Variants vs Scriptable objects.

    Let's say you have 3 kinds of similar items - lets say, health potions (+10 health) , mega potion (+20 health) and super optin (+50 health) they all share the same 3D model / sprite , but with a different parameter for color, and only have a different value in the amount of health healed.

    It's makes more sense to wrap one health option in a prefabs (perhaps a prefab referencing a scripable object) and these three others being prefab variables editable through the inspector.

    just using scriptable onbjects means you'll have to duplicate the 3 health potion files with all their parameters in including ones that are common between them.
     
  36. ChemaDmk

    ChemaDmk

    Unity Technologies

    Joined:
    Jan 14, 2020
    Posts:
    65
    Hey All ! Wow it took me a while to read everything.
    I think the Scriptable object idea is the way to go, and I see that some of you already started with that.

    I feel like we need to define the scope of the inventory so that we are all on the same page.
    I’ve been working on the UI wireframing for the past couple of days, and I needed to do that. So here it goes :

    The Inventory will contain 3 different types of items :
    • Customisation item for the character
    • Ingredients
    • Utensils
    • Dishes
    Ingredients, Utensils and Customisation items are picked up from the world environment.

    Ingredients and Utensils are used to create Dishes.
    Ingredients disappear from the inventory, while Utensils are kept.
    Dishes appear in the inventory after the Ingredients and Utensils are selected then used

    Customisation Items are purely cosmetic. They’re mainly elements that can either be added to the character 3D model (bracelet, hat ... ) or texture changes (new apron color …).
    A Customisation Item can be equipped

    An item is characterised by:
    • A name
    • A preview image and/or a 3D asset
    • A type
    • A description

    Here’s a preview (still WIP) of the Inventory screen

    Note 1: The action button changes depending on the selected item's type :
    -Equip (customisation item)
    -Create dish (Ingredients + Utensils )
    -Eat (Dish)

    Note 2 : When multiple items are selected, they need to be highlighted in the item grid (either different colour, size or border depending on the art). The item preview section either image or text will not display anything.

    And here is the link the UI discussion : https://forum.unity.com/threads/ui-wireframing.987606/#post-6441089
     
  37. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    That is a very nice expanded list of requirements. I created an editor window for the Inventory ScriptableObject, and will push that to the PR. @ChemaDmk is it your preference for us to have the first PR represent all of these items, or do you want multiple PRs/commits? If the latter, I will see if I can get some more people to contribute (so it's not just my PR.)
     
  38. ChemaDmk

    ChemaDmk

    Unity Technologies

    Joined:
    Jan 14, 2020
    Posts:
    65
    @tmcdonald I don't have any preference actually. So whatever suits you best ! I just wanted to clarify the scope :)
     
  39. davejrodriguez

    davejrodriguez

    Joined:
    Feb 5, 2013
    Posts:
    69
    > Ingredients and Utensils are used to create Dishes.
    > Dishes appear in the inventory after the Ingredients and Utensils are selected then used
    > -Eat (Dish)

    So if I'm understanding correctly, this would mean that there would only be one level of crafting/cooking (eg no combining crafted dishes into a more complex dish)?
     
  40. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    @ChemaDmk We had a possibly erroneous assumption that items should have a quantity in the inventory. Did you instead envision that each slot in the inventory would represent a single item?
     
  41. shuttle127

    shuttle127

    Joined:
    Oct 1, 2020
    Posts:
    183
    In the current in progress Miro board there is no combining of dishes. Probably best not to for the sake of time.

    The wireframes show quantity icon in the top right of each item slot, and there hasn’t been a request/suggestion to change it, so I think that assumption is okay.
     
  42. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    Oh good catch! Thanks.
     
  43. davejrodriguez

    davejrodriguez

    Joined:
    Feb 5, 2013
    Posts:
    69
    I mean, according to the board, the player only makes one dish for the King Eye. Not really a great source of detail about the dish mechanics. I'm not banging the drum for more complex dish mechanics either. Just wanted to confirm that's what was meant.
     
  44. Soundguy

    Soundguy

    Joined:
    Oct 30, 2009
    Posts:
    48
    I'm adding those new item fields now based on PR #100
    I'm taking the liberty of adding another field for the item which is which is the actoin's name.
     
  45. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    Cool, the PR branch is here: https://github.com/trevorjmcdonald/open-project-1/tree/trevorjmcdonald/inventory-system-base

    I'm also wondering if the Dictionary setup isn't a good idea, since I'm seeing some of the wireframes have empty slots. Maybe we make the Inventory a List with a max index size. My earlier concept had "ItemStacks." We might want to do that again. That way you could have two "stacks" of carrots, for example, with different quantities.
     
    davejrodriguez likes this.
  46. Soundguy

    Soundguy

    Joined:
    Oct 30, 2009
    Posts:
    48
    Project file organizaiotn - where do you put the configuration scriptable objects files?
     
  47. Soundguy

    Soundguy

    Joined:
    Oct 30, 2009
    Posts:
    48
    re: PR's . I'm not fully familiar with how PR's work in git . can i add my commits to your PR or do i need to make another PR based on yours.
     
  48. davejrodriguez

    davejrodriguez

    Joined:
    Feb 5, 2013
    Posts:
    69
    +1 for this. Might let us use ReorderableList for the Inventory inspector as well.
     
    Last edited: Oct 22, 2020
  49. Soundguy

    Soundguy

    Joined:
    Oct 30, 2009
    Posts:
    48
  50. shuttle127

    shuttle127

    Joined:
    Oct 1, 2020
    Posts:
    183
    Understood, was referring to the board Chema posted in the wireframe thread, not sure if that’s posted anywhere else currently. The cooking/gameplay thread had a ton of suggestions for complex dishes like you’re asking, and so did the dialogue and narrative thread, just seems like the Unity team wants to keep things as simple as possible to start. Looking at the PR, doesn’t seem like it’d be too hard to add that after the fact.

    What would be the downside to having just one big stack with no max quantity? Wouldn’t envision anything in this game is going to be more than 99, right?

    Is this strictly for the editor or does that data type imply the player should be able to sort in the UI? Trying not to go out of scope, but I’d think the structure of items is fairly coupled with the Inventory UI.