Unity INVENTORY: A Definitive Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

ความคิดเห็น • 204

  • @CocoCode
    @CocoCode  26 วันที่ผ่านมา

    want to create even more advanced Inventory?
    👉 Check out my newest course, Master Unity UI ➡ bit.ly/cc-unity-ui-115
    It’s packed with everything you need to create awesome UI ✨🎨

  • @TamaraMakesGames
    @TamaraMakesGames 2 ปีที่แล้ว +55

    This is what I call a nice and thorough tutorial! Well done and thanks a lot for collaborating with me!

  • @CoreyMcintyre-b7k
    @CoreyMcintyre-b7k ปีที่แล้ว +4

    this is taking me hours to skim through this back and forth over and over just to get it right

  • @tbardo3772
    @tbardo3772 ปีที่แล้ว +28

    Honestly incredible, I had not found a tutorial so simple, effective and that goes directly to the point, full of examples, with a minimalist edition and perfect for the understanding of anyone who sees this video. simply incredible, my congratulations.

  • @rebornl
    @rebornl ปีที่แล้ว +48

    For those that have issues moving the item when the count is higher than 1.
    In the InventoryItem class, OnBeginDrag turn off the raycastTarget for the Count Text
    ex. CountText.raycastTarget = false or turn it off in the Prefab
    Also turn it back on in the OnEndDrag function
    ex. CountText.raycastTarget = true

    • @opafmoremedica
      @opafmoremedica ปีที่แล้ว +1

      Thank you! That would've taken me a long time to find. I was getting ready to comb through the code and find out where I botched something

    • @profit_nation
      @profit_nation ปีที่แล้ว

      i love you

    • @OdysseyForge-2024
      @OdysseyForge-2024 11 หลายเดือนก่อน

      Ya, thanks!

    • @Positivectrl
      @Positivectrl หลายเดือนก่อน

      aaah there, thank you kind sir!

  • @realbyte2048
    @realbyte2048 ปีที่แล้ว +4

    I was originally a little skeptical that this system wouldn't be very flexible, but I'm super happy with the end result. Thanks for the tutorial!

  • @DemersCreations
    @DemersCreations ปีที่แล้ว +7

    Here's a quick tip I learned that saves some time. Instead of locking the inspector you can hit the three dots in the inspector for which area you want to keep open and select "Properties". This opens up a floating window with that area for which you can freely drag and drop :)
    Saves you the time of having to Unlock and you can also have multiple floating windows open.

  • @StealthyShiroeanGames
    @StealthyShiroeanGames 10 หลายเดือนก่อน +3

    This was an excellent tutorial! A great starting point for an inventory system. There's definitely a couple other things I'd like to add to this system but I really appreciated just how thorough and succinct it was for a relatively more complex system. Thank you for making this!

  • @grifergaming4721
    @grifergaming4721 ปีที่แล้ว +2

    Man made it easier than brackeys inventory tutorial... hands down to this dude much easier to follow. and less complicated

  • @ghostoflarissa
    @ghostoflarissa 4 หลายเดือนก่อน +1

    Thank you so much for this! I definitely had NOT been crying myself to sleep struggling to code this the past few days

  • @jadivods
    @jadivods ปีที่แล้ว +1

    This tutorial taught us a lot of new things and helped us establish the groundwork for our project, there were some frustrating moments where something didnt work but usually reviewing the code and/or the video held the answer to the problem, thank you!

  • @marcodeavila5621
    @marcodeavila5621 ปีที่แล้ว +19

    Hello, I love the tutorial, very easy and useful, I would like to share this technique that I used to select the items with the scroll wheel of the mouse...
    float scroll = Input.GetAxis("Mouse ScrollWheel");
    if (scroll != 0) // Seleccion con el scroll.
    {
    int newValue = selectedSlot + (int)(scroll / Mathf.Abs(scroll));
    if (newValue < 0)
    {
    newValue = inventorySlots.Length - 1;
    }
    else if (newValue >= inventorySlots.Length)
    {
    newValue = 0;
    }
    ChangeSelectedSlot(newValue);
    }
    One other thing, if you are using TMPro to display the number of items, you need to disable the Raycast Target option which is active by default in the component, otherwise the stackable items cannot be dragged to another slot... hope I helped.

    • @fryptompt
      @fryptompt ปีที่แล้ว

      Hey, first of all thank you for this!
      But I have a problem, when I am scrolling selected slot changes, but it stops after reaching the last slot it does not go to the first slot like Minecraft slot selection, do you have a solution?

    • @marcodeavila5621
      @marcodeavila5621 ปีที่แล้ว

      @@fryptompt I think you're copying the code snippet wrong, or maybe it's something else from your slot arrangement or also check your selection method.

    • @dnbroo
      @dnbroo ปีที่แล้ว +1

      @@fryptompt I was having the same issue. When going through the scroll is was scrolling through items in the invetory page too. To fix this, change the return at the bottom to ChangeSelectedSlot(newValue % [NUMBER OF TOOLBAR SLOTS + 1]). My tool bar has 8 slots so I set it ChangeSelectedSlot(newValue % 9) and that fixed it.

    • @Seshua87
      @Seshua87 7 หลายเดือนก่อน +1

      @@dnbroo Thankyou!

  • @Corummo
    @Corummo ปีที่แล้ว +2

    Best tutorial ever made on the subject. Finally a wise and proper utilisation of the ScriptableObjects concept. Bravo! 👏

    • @CocoCode
      @CocoCode  ปีที่แล้ว +4

      Thank you! 🎉

  • @Sepu1tra
    @Sepu1tra 5 หลายเดือนก่อน

    This 35 minute video saved me hours of troubleshooting and research. Killed it!

  • @emilix_262
    @emilix_262 2 ปีที่แล้ว +17

    A very good tutorial! Can you also make one on a load-save system? Including tile maps, inventory and maybe player settings? Thanks.

  • @macaronicrocs6989
    @macaronicrocs6989 ปีที่แล้ว +3

    Your tutorials are by far the best i've seen! Accurate, intuitive and extremely helpful! :)

  • @bonquaviusdingle5720
    @bonquaviusdingle5720 2 ปีที่แล้ว +5

    This channel is awesome 👍 so glad I found it, keep doing tutorials, cant wait for a nice shader tutorial

  • @acidxcross
    @acidxcross ปีที่แล้ว +2

    This is the best tutorial I've seen. Easy to follow and clean explanation, very helpful.

  • @Jimaniki
    @Jimaniki 2 ปีที่แล้ว +2

    Thank you for coming back doing new tutorials ! :D

  • @sig3l202
    @sig3l202 หลายเดือนก่อน

    Masz bardzo klarowny akcent gdy mówisz po angielsku, fajny i przydatny filmik! :)

  • @fv4202x
    @fv4202x ปีที่แล้ว +4

    If your dragging item is not on the screen, Change canvas type to overlay (not camera)

  • @nyrab.6239
    @nyrab.6239 11 หลายเดือนก่อน

    such a tutorial for the UI toolkit would be amazing! you always explain everything so well, and there are so few tutorials for the toolkit, this would help a lot!

  • @Robin_9944
    @Robin_9944 7 หลายเดือนก่อน

    This tutorial helped me so much for my end project for coding in school! Thank you so much!

  • @nadavmihov
    @nadavmihov 2 ปีที่แล้ว +2

    Wow! This tutorial is so big and cool! keep making tutorials!

  • @GammingPotato
    @GammingPotato ปีที่แล้ว

    After having spent hours working I was able to make it through this tutorial with a working inventory, Thanks! :D

  • @danielrosenberg7174
    @danielrosenberg7174 ปีที่แล้ว +4

    Great vid btw. Would be nice if we can combine and split stacks 2. a tip for the rest to make it even more performant. put an if statement before the loop checking if its stackable or not instead of checking it for every slot and then doing the empty check loop.

    • @Coleslaw333
      @Coleslaw333 ปีที่แล้ว +1

      You Can Combine Them By Changing Your OnEndDrag() function To This
      public void OnEndDrag(PointerEventData Data)
      {
      Image.raycastTarget = true;
      InventoryItem InvItem = Data.pointerEnter.GetComponent();
      if(InvItem && Item == InvItem.Item)
      {
      InvItem.Count += Count;
      InvItem.RefreshCount();
      Destroy(gameObject);
      }
      else
      {
      transform.SetParent(ParentAfterDrag);
      }
      }
      I'm not sure how to split stack tho

  • @TheKr0ckeR
    @TheKr0ckeR 2 ปีที่แล้ว +1

    thanks mate. I was always wondering modular inventory system

  • @danielanselmi258
    @danielanselmi258 ปีที่แล้ว +1

    Just an Amazing job ! 🙏 very selfexplanatory and clear knowledge transfer! Keep up the good work

  • @matthias2122
    @matthias2122 ปีที่แล้ว +2

    Great Tutorial keep up the great work!!! What Color Theme are you using?

  • @DeveloperJake
    @DeveloperJake 2 ปีที่แล้ว +4

    No way
    This is actually a cool tutorial

    • @CocoCode
      @CocoCode  2 ปีที่แล้ว +1

      Thanks! It was a difficult video to pull off, because of its complexity, but hopefully everyone will be able to follow along with all infographics and explanations along the way 👨‍💻

  • @chriscamp9788
    @chriscamp9788 ปีที่แล้ว +3

    Incredible tutorial. A great starting point for almost all of my learning in unity. Thanks a ton!

  • @csr3846
    @csr3846 ปีที่แล้ว

    This is one of the cleanest inventory tutorials i've come across here on youtube. Great job! Subscribed.
    How would you go about dropping an item out of the inventory bounds to remove it from the inventory entirely?

    • @csr3846
      @csr3846 ปีที่แล้ว

      I found a way.. rather clumsy, but works for now.
      public void OnEndDrag(PointerEventData eventData)
      {
      if(eventData.pointerEnter == null) {
      // outside of inventory
      }
      }

  • @DrawMaster115
    @DrawMaster115 ปีที่แล้ว

    Pretty Good video, You explain mostt stuff pretty well. I ran into some issues when I tried to sort the inventory. Particularly with Destroying a inventoryitem and then in the same function checking if it is null. This is because the Destroy does not happen until the next Update. Also including some features or direction for how to make the inventory controller accesable would be good. Overall great tutorial!!!

  • @oggy4019
    @oggy4019 ปีที่แล้ว

    Absolute cool tutorial, all of instruction are clear, i hope i can add some features by myself

  • @sharp5624
    @sharp5624 หลายเดือนก่อน

    Thank you soo much for this tutorial !!!
    It helped me to understand crucial fundamentals of inventory management.
    It also kick-started coding future futures on my own. I added merging items and scrolling through ability.
    If anyone out there would be interested i can share the code.

  • @venesardthethief6704
    @venesardthethief6704 ปีที่แล้ว +3

    Hey! Great tutorial :) But one thing bothers me.. How can I replace items on drag'n'drop in the system you've showed in the video? I mean, drop a pickaxe in the place of the shovel, and they will swap. Would love to see some tips!

    • @venesardthethief6704
      @venesardthethief6704 ปีที่แล้ว +4

      If someone else would look for solution - I got it to work. We need to add another condition in "InventorySlot" script.
      if (transform.childCount == 1)
      {
      InventoryItem inventoryItem = eventData.pointerDrag.GetComponent();
      InventoryItem oldItem = transform.GetComponentInChildren();
      oldItem.transform.SetParent(inventoryItem.oldParent);
      inventoryItem.parentAfterDrag = transform;
      }
      Also, we need to define public Transform oldParent in "InventoryItem" script and set it up in the same place where parentAfterDrag is set.
      And that's all, it works!

    • @AfridiAE
      @AfridiAE 10 หลายเดือนก่อน

      @@venesardthethief6704 Your code for me doesn't work dragged item to already occupied slot simply vanishes for me
      here is my code with swapping implemented. i hope it helps.
      // in inventorySlot Code add this:
      private InventoryItem currentItem;
      // replace your OnDrop with:
      public void OnDrop(PointerEventData eventData) {
      if (transform.childCount == 0) {
      InventoryItem inventoryItem = eventData.pointerDrag.GetComponent();
      inventoryItem.parentAfterDrag = transform;
      inventoryItem.transform.SetParent(transform);
      inventoryItem.transform.localPosition = Vector3.zero;
      inventoryItem.OnEndDrag(eventData);
      } else {
      InventoryItem newItem = eventData.pointerDrag.GetComponent();
      SwapItems(newItem);
      }
      }
      // Add this:
      private void SwapItems(InventoryItem newItem) {
      currentItem = GetComponentInChildren();
      currentItem.parentAfterDrag = newItem.parentAfterDrag;
      currentItem.transform.SetParent(newItem.parentAfterDrag);
      currentItem.transform.localPosition = Vector3.zero;
      currentItem.OnEndDrag(null);
      newItem.parentAfterDrag = transform;
      newItem.transform.SetParent(transform);
      newItem.transform.localPosition = Vector3.zero;
      newItem.OnEndDrag(null);
      }
      In InventoryItem script
      Simply replace yours with mine:
      public void OnEndDrag(PointerEventData eventData) {
      image.raycastTarget = true;
      transform.SetParent(parentAfterDrag);
      transform.localPosition = Vector3.zero;
      }

    • @emilian_spielt300
      @emilian_spielt300 8 หลายเดือนก่อน

      even tho you wrote this 6 month ago it still found its use, thanks man you really helped me out on this.@@venesardthethief6704

  • @firecreeper9059
    @firecreeper9059 7 หลายเดือนก่อน

    Hey, so i'm making a 3d survival game and I was wondering how would I be able to make it where you see what your using/holding
    Excellent content btw, explained everything so nicely!

  • @manuelgraca-gamedev7822
    @manuelgraca-gamedev7822 2 ปีที่แล้ว +2

    Amazing as always!!

  • @leLawain
    @leLawain ปีที่แล้ว

    Hey, good video!
    What kind of Visual Studio are you using that you get all these colorful highligths?

  • @tempoz2403
    @tempoz2403 6 หลายเดือนก่อน

    Good guide, but I'd like to know how you can make the discarding of items when releasing the cursor outside the inventory (the selected item should be removed from the inventory box and appear under the player or in the place where the cursor was released) Also need the reverse logic of picking up items, so that the lying item can be picked up in the inventory box
    P.S.: I'm developing a top-down game like Dont Starve.

  • @OliverWendelin
    @OliverWendelin ปีที่แล้ว

    Really awesome tutorial! Is there any chance you would expand on that? such as showing a selected Item/weapon on a character and decreasing the correct ammunition for it (arrows, bullets etc.) when stored in a different slot?

  • @YuriNoirProductions
    @YuriNoirProductions ปีที่แล้ว +1

    this tutorial is beyond stellar. its not only easy to follow but also most solutions are super elegantly implemented.
    i only had a single issue. ater i added stacking items with a stack where not able to be dropped into another slot anymore. any idea what might be causing this?

    • @YuriNoirProductions
      @YuriNoirProductions ปีที่แล้ว +3

      As always... asking the question instantly helped me to find the solution... newer Unity Versions don't support regular Text anymore and thus you have to use Text Mesh Pro. Text Mesh Pro however is by default a raycast target and you have to open the advanced settings and disable it so your Count Text does not Catch the Drop Event

  • @monke3202
    @monke3202 8 หลายเดือนก่อน +1

    Incredible tutorial

  • @jovanzivkovic7053
    @jovanzivkovic7053 2 ปีที่แล้ว +1

    Hey will you make an Inventory Tutorial with Playfab? Where we also can create a store for players online.I love your tutorials they are all amazing!!

  • @frontend_ko
    @frontend_ko 3 หลายเดือนก่อน

    Thank you sincerely 9:36

  • @erkan2284
    @erkan2284 2 ปีที่แล้ว +2

    27:09 my preferred solution for change selected item is
    private void ChangeSelectedIfNumberPressed()
    {
    if (Input.inputString == null)
    {
    return;
    }
    if (!int.TryParse(Input.inputString, out int number))
    {
    return;
    }
    if(number > 7) {
    return;
    }
    ChangeSelectedSlot((number - 1) % 10);
    }

  • @5of
    @5of หลายเดือนก่อน +1

    can you add drop item pleaseee

  • @giovannigiorgio1536
    @giovannigiorgio1536 หลายเดือนก่อน

    How do you stretch with rectangle tool symmetrically? I try shift and it's only doing uniform scale.
    Great video, thanks!
    PS. It is pressing and holding Alt after the start of the dragging.

  • @kacpermaciag9595
    @kacpermaciag9595 ปีที่แล้ว

    Best tutorial on TH-cam!!

  • @KennyComicx
    @KennyComicx ปีที่แล้ว

    Thank you so much for the tutorial ^_^ Is there anyway to make it so only a specific ItemType can go on a certain slot ItemSlot? How would i go about doing that and which scripts would i need to change? Thanks!

  • @healky
    @healky 2 หลายเดือนก่อน +1

    How to make items with unique values like durablity

  • @WGuy08
    @WGuy08 6 หลายเดือนก่อน

    Great tutorial! The only problem i have is when i drag the image will disappear while dragging

  • @CosmicDish
    @CosmicDish ปีที่แล้ว

    Best unity dev

  • @Nahciak
    @Nahciak ปีที่แล้ว +2

    swietny kanal

  • @freepik19nineteen2
    @freepik19nineteen2 ปีที่แล้ว +1

    Hi Very Great tutorial thanks.
    can you make a tutorial on how to blur UI button without changing the canvas from screen space overlay to screen space camera?
    Thanks again for such a great tutorial! 🤩🤩🤩

  • @4speed202
    @4speed202 ปีที่แล้ว

    Easy to understand, thank you :D

  • @cjmars
    @cjmars 11 หลายเดือนก่อน +2

    My inventory item kept disappearing while being dragged. In case anyone has this problem, I finally figured out that for me it was because my Canvas was not at the root level of the scene.

    • @chiekokurokumo
      @chiekokurokumo 11 หลายเดือนก่อน +1

      Ahh... thank you.

    • @connorwilson-long1336
      @connorwilson-long1336 10 หลายเดือนก่อน

      Could you please explain what that means. I am having the same problem and my canvas is apart of a player that is instantiated at the start of the game.

    • @cjmars
      @cjmars 10 หลายเดือนก่อน

      @@connorwilson-long1336 Make sure your Canvas object in the scene manager is at the top level. If you have it nested under a game object (like an empty game object called 'UI', or the 'Player' game object for example) then it won't work.

  • @flowersfish1348
    @flowersfish1348 2 ปีที่แล้ว

    Please Upload More ur Video is so usefull ...

  • @waterrrrrr49
    @waterrrrrr49 ปีที่แล้ว +1

    How would i make it so that when an item is selected a game object in the scene is enabled? thank you

  • @markflakezCG
    @markflakezCG ปีที่แล้ว +4

    Awesome Tutorial. I have one problem tho. I can only drag Items with the count of one in other inventoryslots. Anything higher is still draggable but will return in it's original slot. Any idea why? I checked all the code multiple times now :(

    • @markflakezCG
      @markflakezCG ปีที่แล้ว +1

      @@waschwolf0766 It actually solved it.. I can't thank you enough!! I would never have thought this was the problem.

    • @markdanisovszky368
      @markdanisovszky368 ปีที่แล้ว

      Same issue and i already using the Legacy Text element :(

    • @markdanisovszky368
      @markdanisovszky368 ปีที่แล้ว +2

      Solved: Just resized the text element size (i made it smaller) and works now!

    • @stepannovoselov4072
      @stepannovoselov4072 ปีที่แล้ว +5

      OnBeginDrag: countText.raycastTarget = false;
      OnEndDrag: countText.raycastTarget = true;

    • @HouseTrapJay
      @HouseTrapJay ปีที่แล้ว +1

      @@stepannovoselov4072 ^^^ This is the fix. Great stuff and thank you. Never would've guessed the Text was the culprit here without these comments.

  • @bestofgame887
    @bestofgame887 ปีที่แล้ว +2

    i found a bug and would love it if u do a small soultion for it
    if you drag item while the inventury full and there is a item on the Ground, the item will take the place and u left up
    with a full Inventury with no place for the Dragged Item

    • @ChronomancerDe
      @ChronomancerDe ปีที่แล้ว

      Just make it imposible to pick up items while in Inventory.

    • @lewuko5688
      @lewuko5688 ปีที่แล้ว

      i have fixed mine by adding boolean in inventoryItem and PickupItem called it isDraggingItem turn it on if on Begin drag and turn it off in End Drag then i use if statment in InventoryManager add item funcation , by doing if (!isDraggingItem)
      { all add part below } return false; ,, long story short can be fixed if you use boolean.

  • @arisaek7764
    @arisaek7764 ปีที่แล้ว

    you sir are amaizing!

  • @Shonia
    @Shonia ปีที่แล้ว

    Awesome video!

  • @cmapez
    @cmapez ปีที่แล้ว +1

    God's tutorial.

  • @Education_Platform-Block211
    @Education_Platform-Block211 2 ปีที่แล้ว

    Hey! Can you make tutorial about grid based inventory? Like a Inventory in Escape from Tarkov?

  • @samluo7369
    @samluo7369 2 หลายเดือนก่อน +2

    any one have the same problem?
    around 11:00; when i try to initialize item; in unity; In unity no image can load and it keep saying
    NullReferenceException: Object reference not set to an instance of an object

    • @favorax
      @favorax หลายเดือนก่อน

      did you fix it by any chance?

    • @jumanian7346
      @jumanian7346 26 วันที่ผ่านมา

      It's probably because you need to put the InventoryItem gameobject into the Inventory Item Prefab section on the InventoryManager

    • @klubbu
      @klubbu ชั่วโมงที่ผ่านมา

      In my case the issue was that I didn't have the image property of the script on InventoryItem set to the object itself as seen at around 7:18.

  • @FelinaFaerlaingal
    @FelinaFaerlaingal ปีที่แล้ว

    Do you have a connected tutorial to save the inventory between game sessions? I thought scriptable objects couldn't be serialized (and thus saved) in unity, which is why I'm confused

  • @Yonnorr
    @Yonnorr ปีที่แล้ว

    has anyone implemented splitting stacks at all? Curious to see how people achieved that

  • @sylwestertadyniewicz5876
    @sylwestertadyniewicz5876 10 หลายเดือนก่อน

    How can I lift an object from, for example, the ground ? With the help of this great tutorial :)

    • @CocoCode
      @CocoCode  10 หลายเดือนก่อน

      That is covered at the end of this video when we merge projects with Tamara :)

  • @charlesgouvion3718
    @charlesgouvion3718 ปีที่แล้ว

    Hi, Can you make a second video where you explain and teach us how to make a GameManager for this inventory ? to change scene with it
    thank u

  • @antonjjohansson
    @antonjjohansson ปีที่แล้ว +1

    Hello, I found a problem, either I missed something or it's gone passed without noticing but if I got a stackable item that only got a count of 1 I am able to move it between slot, but as soon as I got 2 or more counts of it in a slot I can't move it anymore between slots.

    • @kootsy2465
      @kootsy2465 ปีที่แล้ว +3

      OnBeginingDrag : countText.raycastTarget = false;
      OnEndDrag: countText.raycastTarget = true;

    • @antonjjohansson
      @antonjjohansson ปีที่แล้ว

      @@kootsy2465 Life saver man! Thank you!

    • @kootsy2465
      @kootsy2465 ปีที่แล้ว +2

      @@antonjjohansson gotchu

    • @Kyami.
      @Kyami. ปีที่แล้ว +1

      @@kootsy2465 thank you friends

  • @randomrech5666
    @randomrech5666 ปีที่แล้ว +1

    34:20 Do you know how to do so that when you do not have any items in the inventory you do not receive the nullReferenceException error?

    • @capeto.
      @capeto. ปีที่แล้ว

      hi, Have you solved it?

  • @Cybarxz
    @Cybarxz ปีที่แล้ว +1

    Are we still having a scriptable obj video?

  • @Im_The_Immortal_Snail
    @Im_The_Immortal_Snail 2 หลายเดือนก่อน

    for some reason unity sees all slots as empty when dragging but as it should be when spawning/ picking up items how would i fix this?

  • @marixcool
    @marixcool ปีที่แล้ว

    great video !

  • @antonjjohansson
    @antonjjohansson ปีที่แล้ว

    How would I implement an amount in the AddItem(item, amount) ? I am making a loot script and want to add more than one of the same object.

  • @FadiFlashi
    @FadiFlashi ปีที่แล้ว

    I'm struggling to translate this into a photon multiplayer inventory system :( Does anyone know a good tutorial or way to do it online?

  • @jellejankowski2239
    @jellejankowski2239 ปีที่แล้ว

    Is it also possible to make a pickaxe interact with more tilebases than just one? because I want a pickaxe to mine more blocks than just 1

  • @HMaster28
    @HMaster28 9 หลายเดือนก่อน +1

    why am i getting the error Assets\InventorySlot.cs(13,78): error CS0246: The type or namespace name 'InventoryItem' could not be found (are you missing a using directive or an assembly reference?)

    • @IgorYonezawa
      @IgorYonezawa 4 หลายเดือนก่อน

      me too

    • @IgorYonezawa
      @IgorYonezawa 4 หลายเดือนก่อน

      Put that on ur code..
      using UnityEngine.EventSystems;

    • @BIZAAL
      @BIZAAL 12 วันที่ผ่านมา

      To fix it just make the i on the last "inventoryItem" a lowercase

  • @simonjares3780
    @simonjares3780 ปีที่แล้ว

    I have a question, i am implementing this into my mobile project but i dont know how i can get the selected slot from buttons, thanks in advance.

  • @trentontyee2552
    @trentontyee2552 ปีที่แล้ว

    there’s a problem with item stacking for mine, ive narrowed it down to my code can’t detect if the item in slot is equal to the item your getting and i can’t figure out why

  • @kaio9637
    @kaio9637 ปีที่แล้ว

    nice video man.

  • @vexor699
    @vexor699 2 ปีที่แล้ว

    here before it goes viral

    • @kmazit
      @kmazit 2 ปีที่แล้ว

      yes

  • @LLAGASLorenze
    @LLAGASLorenze ปีที่แล้ว

    That's one big tutorial for me to my game, yet I have one question....How can the item be undraggable once it is dropped? I really wish that's in that tutorial, I can't find any other...

    • @CocoCode
      @CocoCode  ปีที่แล้ว +1

      That's a quite custom request for such system. You should be able to achieve that by setting in OnEndDrag: image.raycastTarget to false (6:17)

    • @LLAGASLorenze
      @LLAGASLorenze ปีที่แล้ว

      @@CocoCode Yes HAHA, it worked...Thank You very much

  • @tahakh9378
    @tahakh9378 ปีที่แล้ว

    man, thats what i want

  • @GameDevCaptainBlack
    @GameDevCaptainBlack 9 หลายเดือนก่อน

    Thank You

  • @DemersCreations
    @DemersCreations ปีที่แล้ว

    Okay so here is my scenario. When raycasting a tagged "pickupable" && player presses E, I want to be able to destroy game object and then add it to my inventory. I have this functionality on a seperate Pickupsystem script. How would I go about doing this? I you all need more info let me know.

  • @akhilldhilipkumarkalaiyara1601
    @akhilldhilipkumarkalaiyara1601 10 หลายเดือนก่อน

    Im having a bug where when you select the first slot it doesnt show any slot being selected, but when you select any other slot it and the first slot are selected.

  • @alikarimi7056
    @alikarimi7056 ปีที่แล้ว

    I wanted to add a child object to inventroySlot prefab But when I did, after adding inventoryItem, everything in inventorySlot messed up. how can I have multiple child (i.e. a ribbon around the selected slot) for that ?

  • @hirosacraftsmp8278
    @hirosacraftsmp8278 ปีที่แล้ว

    does this work for the new input system ??

  • @stepannovoselov4072
    @stepannovoselov4072 ปีที่แล้ว +1

    how drop my items?

  • @ErstMalTeee
    @ErstMalTeee ปีที่แล้ว

    Ok now how do I make another Object Active, when it is selected? Like I have a Script, and in this script I want to say: If(SelectedItem = Axe){Make Axe Active} else{disable axe} or something like this. How would I do that?

  • @alvrmiguel
    @alvrmiguel ปีที่แล้ว +2

    To switch items between slots:
    public void OnDrop(PointerEventData eventData)
    {
    DraggableItem draggableItem = eventData.pointerDrag.GetComponent();
    if (draggableItem != null)
    {
    if (transform.childCount == 0)
    {
    // empty slot move
    draggableItem.parentAfterDrag = transform;
    draggableItem.transform.SetParent(transform);
    }
    else
    {
    // Switch between slots
    Transform otherItem = transform.GetChild(0);
    Transform originalParent = draggableItem.parentAfterDrag;
    draggableItem.parentAfterDrag = transform;
    draggableItem.transform.SetParent(transform);
    otherItem.GetComponent().parentAfterDrag = originalParent;
    otherItem.SetParent(originalParent);
    }
    }
    }

  • @abdurrehmanmuhammad6267
    @abdurrehmanmuhammad6267 ปีที่แล้ว

    Is it possible to drag the items for Inventory to the actual game?

  • @daniilgorbachev
    @daniilgorbachev 2 ปีที่แล้ว

    lol why does it seem to me that soon he will show how to make a full-fledged Minecraft with multiplayer 😂

  • @Fluffyman2271
    @Fluffyman2271 ปีที่แล้ว

    This is the 100th comment. This tutorial was very helpful

  • @Hadis_Yolculugu
    @Hadis_Yolculugu ปีที่แล้ว +1

  • @mosamansha
    @mosamansha 4 หลายเดือนก่อน

    bro can you make a video on dropping items

    • @rrainix
      @rrainix 4 หลายเดือนก่อน +1

      just put a gameobject in the scriptable object which will be assigned as the drop item, as soon as you press the drop button the dropitem will be instantiated infront or near the players position

  • @ObiGobiGames
    @ObiGobiGames 10 หลายเดือนก่อน

    When I make the inventory a child of my player character prefab (I have a multiplayer game) the items disappear when dragging (but everything else works fine). What changes would I need to make to the code?

    • @FlizzyGlizzy
      @FlizzyGlizzy 4 หลายเดือนก่อน

      same here bro

    • @doiknowu6213
      @doiknowu6213 3 หลายเดือนก่อน +1

      @@FlizzyGlizzy there are 2 kind of issues you are meeting, if it's teleported in the middle of nowhere (you can check it by selecting and drag to check it's pros x,y), or it legit "dissapear" behind the other UI
      for the teleporting: it because of the canvas render mode you are using is world space, you need to change it to screen space - overlay and resize it by using canvas scaler.
      for the "dissapearing" behind the other UI, it's possible that your canvas isn't at the root level of the scene hierarchy (example: you are creating a canvas inside an empty object, so when you drag, the canvas no longer detect the item as its children anymore [i maybe wrong but that's what i solved])

  • @bloodborne_pc_2025
    @bloodborne_pc_2025 ปีที่แล้ว

    when I try to drag an drop an item to a new slot, the item just snaps back to the original slot, does anybody else get this?