Unity INVENTORY: A Definitive Tutorial

🏗 ‪@TamaraMakesGames‬ building system video: • 2D Grid Building Syste...
🏞 FREE assets download: www.patreon.com/posts/7263139...
🎁 Support me and DOWNLOAD Unity project: www.patreon.com/posts/7263241...
This tutorial guide will show you how to create a full inventory system with draggable items, bottom toolbar, full inventory UI and stackable items. Please use video chapters to travel between video sections and learn more effectively.
--------------------------------------------------------------------------------
👨‍💻 SOCIALS:
💜 Join our Discord: / discord
🔵 Follow me on Twitter: / bionicl333
--------------------------------------------------------------------------------
🎓 YOU WILL LEARN:
- How to create Unity inventory system
- How to integrate inventory with the building system
- Unity item stacks
- Inventory toolbar
- Inventory like in Minecraft made with Unity
--------------------------------------------------------------------------------
⚙️ VIDEO CHAPTERS:
0:00 - Intro
0:56 - Building the UI
3:53 - Showing/hiding main inventory
5:18 - Inventory drag and drop
7:00 - Items scriptable objects
9:28 - Initialise inventory items based on scriptable objects
11:02 - Finding free slot in the inventory
14:15 - Spawning new item
17:27 - Checking if the inventory if full
19:01 - Stacking items
23:06 - Showing selected slot
26:06 - Changing selected slot
27:13 - Using items
30:50 - Integrating with Tamara game

Пікірлер: 185

  • @TamaraMakesGames
    @TamaraMakesGames Жыл бұрын

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

  • @jadimatic1096
    @jadimatic109611 ай бұрын

    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!

  • @StealthyShiroeanGames
    @StealthyShiroeanGames6 ай бұрын

    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!

  • @realbyte2048
    @realbyte2048 Жыл бұрын

    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!

  • @rebornl
    @rebornl Жыл бұрын

    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

    11 ай бұрын

    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

    11 ай бұрын

    i love you

  • @OdysseyForge-2024

    @OdysseyForge-2024

    6 ай бұрын

    Ya, thanks!

  • @tbardo3772
    @tbardo3772 Жыл бұрын

    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.

  • @user-dh7ry4sc6v
    @user-dh7ry4sc6v9 ай бұрын

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

  • @macaronicrocs6989
    @macaronicrocs6989 Жыл бұрын

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

  • @Jimaniki
    @Jimaniki Жыл бұрын

    Thank you for coming back doing new tutorials ! :D

  • @nyrab.6239
    @nyrab.62397 ай бұрын

    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!

  • @nadavmihov
    @nadavmihov Жыл бұрын

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

  • @acidxcross
    @acidxcross Жыл бұрын

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

  • @GammingPotato
    @GammingPotato Жыл бұрын

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

  • @bonquaviusdingle5720
    @bonquaviusdingle5720 Жыл бұрын

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

  • @Sepu1tra
    @Sepu1traАй бұрын

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

  • @Robin_9944
    @Robin_99443 ай бұрын

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

  • @danielanselmi258
    @danielanselmi25810 ай бұрын

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

  • @manuelgraca-gamedev7822
    @manuelgraca-gamedev7822 Жыл бұрын

    Amazing as always!!

  • @Corummo
    @Corummo Жыл бұрын

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

  • @CocoCode

    @CocoCode

    Жыл бұрын

    Thank you! 🎉

  • @DemersCreations
    @DemersCreations Жыл бұрын

    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.

  • @grifergaming4721
    @grifergaming4721 Жыл бұрын

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

  • @marcodeavila5621
    @marcodeavila5621 Жыл бұрын

    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 { 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

    Жыл бұрын

    @@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

    3 ай бұрын

    @@dnbroo Thankyou!

  • @emilix_262
    @emilix_262 Жыл бұрын

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

  • @oggy4019
    @oggy4019 Жыл бұрын

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

  • @chriscamp9788
    @chriscamp9788 Жыл бұрын

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

  • @TheKr0ckeR
    @TheKr0ckeR Жыл бұрын

    thanks mate. I was always wondering modular inventory system

  • @DrawMaster115
    @DrawMaster11511 ай бұрын

    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!!!

  • @monke3202
    @monke32024 ай бұрын

    Incredible tutorial

  • @Shonia
    @Shonia Жыл бұрын

    Awesome video!

  • @kacpermaciag9595
    @kacpermaciag9595 Жыл бұрын

    Best tutorial on KZread!!

  • @4speed202
    @4speed202 Жыл бұрын

    Easy to understand, thank you :D

  • @danielrosenberg7174
    @danielrosenberg7174 Жыл бұрын

    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

    10 ай бұрын

    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

  • @DeveloperJake
    @DeveloperJake Жыл бұрын

    No way This is actually a cool tutorial

  • @CocoCode

    @CocoCode

    Жыл бұрын

    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 👨‍💻

  • @arisaek7764
    @arisaek7764 Жыл бұрын

    you sir are amaizing!

  • @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?

  • @marixcool
    @marixcool10 ай бұрын

    great video !

  • @fv4202x
    @fv4202x10 ай бұрын

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

  • @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?

  • @waterrrrrr49
    @waterrrrrr49 Жыл бұрын

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

  • @matthias2122
    @matthias2122 Жыл бұрын

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

  • @firecreeper9059
    @firecreeper90593 ай бұрын

    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!

  • @KennyClipz
    @KennyClipz Жыл бұрын

    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!

  • @leLawain
    @leLawain Жыл бұрын

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

  • @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 } }

  • @Nahciak
    @Nahciak Жыл бұрын

    swietny kanal

  • @jovanzivkovic7053
    @jovanzivkovic7053 Жыл бұрын

    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!!

  • @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

  • @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

  • @jellejankowski2239
    @jellejankowski22399 ай бұрын

    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

  • @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.

  • @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.

  • @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 ?

  • @WGuy08
    @WGuy082 ай бұрын

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

  • @akhilldhilipkumarkalaiyara1601
    @akhilldhilipkumarkalaiyara16016 ай бұрын

    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.

  • @kaio9637
    @kaio9637 Жыл бұрын

    nice video man.

  • @abdurrehmanmuhammad6267
    @abdurrehmanmuhammad626710 ай бұрын

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

  • @EllsDev
    @EllsDev6 ай бұрын

    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?

  • @kutayperk
    @kutayperk27 күн бұрын

    Guys If there is an item in the inventory that is not in the selected slot, I want it to be deleted. Can you help me

  • @tabsoncode
    @tabsoncode Жыл бұрын

    Does anyone know how I would create a chest system with this code?

  • @Cazaril
    @Cazaril9 ай бұрын

    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?

  • @tempoz2403
    @tempoz24032 ай бұрын

    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.

  • @freepik19nineteen2
    @freepik19nineteen2 Жыл бұрын

    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! 🤩🤩🤩

  • @CosmicDish
    @CosmicDish Жыл бұрын

    Best unity dev

  • @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?

  • @flowersfish1348
    @flowersfish1348 Жыл бұрын

    Please Upload More ur Video is so usefull ...

  • @hirosacraftsmp8278
    @hirosacraftsmp8278 Жыл бұрын

    does this work for the new input system ??

  • @Yonnorr
    @Yonnorr10 ай бұрын

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

  • @CaptainBlackSea
    @CaptainBlackSea5 ай бұрын

    Thank You

  • @erkan2284
    @erkan2284 Жыл бұрын

    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); }

  • @Education_Platform-Block211
    @Education_Platform-Block211 Жыл бұрын

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

  • @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

  • @stepannovoselov4072
    @stepannovoselov4072 Жыл бұрын

    how drop my items?

  • @Cybarxz
    @Cybarxz Жыл бұрын

    Are we still having a scriptable obj video?

  • @UpcomingPlayChannel
    @UpcomingPlayChannel Жыл бұрын

    Hey everyone. Anyone can tell me how i can add mouse click sellect?

  • @randomrech5666
    @randomrech5666 Жыл бұрын

    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.

    11 ай бұрын

    hi, Have you solved it?

  • @YuriNoirProductions
    @YuriNoirProductions Жыл бұрын

    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

    Жыл бұрын

    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

  • @manrrikemorais9329
    @manrrikemorais9329 Жыл бұрын

    save and Load?

  • @gamoe
    @gamoe Жыл бұрын

    thanks you

  • @Fluffyman2271
    @Fluffyman2271 Жыл бұрын

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

  • @bestofgame887
    @bestofgame887 Жыл бұрын

    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.

  • @venesardthethief6704
    @venesardthethief670411 ай бұрын

    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

    11 ай бұрын

    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

    6 ай бұрын

    @@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

    4 ай бұрын

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

  • @kaptniglo7706
    @kaptniglo77062 ай бұрын

    im a total beginner with unity/ scriptig etc.. i tried to figure for an hour how you where able to fit the image of the InventoryItem into the Image, turns out its the gameobject thats needs to be there maybe i should have watched the other vid first nice tutorial tho

  • @LilzkGaming
    @LilzkGaming Жыл бұрын

    Can this be used for a 3d game

  • @CocoCode

    @CocoCode

    Жыл бұрын

    Of course! You just need to hook up prepared methods to your game logic

  • @artris_lotyt4979
    @artris_lotyt4979 Жыл бұрын

    I have a problem, I want to make that when I select an Item, a script read his id and depend of the object it active a weapon. Well my code is "if(item.itemId == 1) --> gun.SetActive(true)" but when I select an empty slot, the game crash because there ids not any item to read his id and I don't know how to fix it

  • @DemersCreations

    @DemersCreations

    Жыл бұрын

    Maybe learn more about Dictionaries? You could set your item ID's in a dictionary and change them around. I think the computer has trouble figuring out what is the actual item in the slot when it comes to ScriptableObjects. Not sure though

  • @artris_lotyt4979

    @artris_lotyt4979

    Жыл бұрын

    @@DemersCreations ok thanks

  • @antonjjohansson
    @antonjjohansson Жыл бұрын

    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

    Жыл бұрын

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

  • @antonjjohansson

    @antonjjohansson

    Жыл бұрын

    @@kootsy2465 Life saver man! Thank you!

  • @kootsy2465

    @kootsy2465

    Жыл бұрын

    @@antonjjohansson gotchu

  • @Kyami.

    @Kyami.

    Жыл бұрын

    @@kootsy2465 thank you friends

  • @jetsi604
    @jetsi604 Жыл бұрын

    Everything works until I try to click that spawn item button, It spawns my items downward instead of horizontal to the right.. I saw that the all clones get parented to the first inventory slot, but why?

  • @tbardo3772

    @tbardo3772

    Жыл бұрын

    in the "InventoryManager" script, you put "GetComponent" instead of "GetComponentInChildren"

  • @jetsi604

    @jetsi604

    Жыл бұрын

    Bit late but I checked and I had "GetComponent" and then edited and tried "GetComponentInChildren" and it worked. I think I didn't watch the video enough closely. But thanks for noticing that and now I got mine work!

  • @HMaster28
    @HMaster285 ай бұрын

    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

    17 күн бұрын

    me too

  • @IgorYonezawa

    @IgorYonezawa

    17 күн бұрын

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

  • @vexor699
    @vexor699 Жыл бұрын

    here before it goes viral

  • @kmazit

    @kmazit

    Жыл бұрын

    yes

  • @markflakezCG
    @markflakezCG Жыл бұрын

    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

    Жыл бұрын

    @@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

    Жыл бұрын

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

  • @stepannovoselov4072

    @stepannovoselov4072

    Жыл бұрын

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

  • @HouseTrapJay

    @HouseTrapJay

    Жыл бұрын

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

  • @burgundyboysyt2272
    @burgundyboysyt2272 Жыл бұрын

    How to fix this error So basically I made a little script where I can drop items And pick them up When I drop the item I can keep dropping the item by the item is out of my inventory The Duping them I don't know way to refresh the inventory when I drop an item Here is the code that I wrote public Item DestroyItemInSlot() { InventorySlot slot3 = inventorySlots[15]; InventoryItem itemInSlot3 = slot3.GetComponentInChildren(); if (itemInSlot3 != null) { Destroy(itemInSlot3.gameObject); } return null; }

  • @tahakh9378
    @tahakh9378 Жыл бұрын

    man, thats what i want

  • @cmapez
    @cmapez Жыл бұрын

    God's tutorial.

  • @sylwestertadyniewicz5876
    @sylwestertadyniewicz58766 ай бұрын

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

  • @CocoCode

    @CocoCode

    6 ай бұрын

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

  • @jeap-k1555
    @jeap-k1555 Жыл бұрын

    Does "inventory drag and drop" section work also for mobile games ?

  • @CocoCode

    @CocoCode

    Жыл бұрын

    Of course! You only need to make sure that the touch target will be big enough

  • @jeap-k1555

    @jeap-k1555

    Жыл бұрын

    But at OnDrag() function at transform.position = Input.mousePosition did i need to change it ? Because on mobile games i need to use Touch Input. Do you know what i need to change there ?

  • @CocoCode

    @CocoCode

    Жыл бұрын

    In such case a first finger position is mapped as Input.mousePosition.

  • @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

    Жыл бұрын

    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

  • @deindeveloper
    @deindeveloper Жыл бұрын

    this is great but can someone help me i have an error in Inventory manager on line: 15 and it calling object reference not set to an instance of an objects pls help :) awesome tutorial :D

  • @Noroh_

    @Noroh_

    Жыл бұрын

    Hi! I have the same problem, have you found the solution?

  • @deindeveloper

    @deindeveloper

    Жыл бұрын

    @@Noroh_ no

  • @tuxvec8777

    @tuxvec8777

    Жыл бұрын

    make sure in the inspector to move the image component into the script slot

  • @daniilgorbachev
    @daniilgorbachev Жыл бұрын

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

  • @baldchessman
    @baldchessman Жыл бұрын

    Anyone have an idea on how id go about saving and loading with this system (with json)

  • @baldchessman

    @baldchessman

    Жыл бұрын

    I figured it out

  • @vansnarky5905

    @vansnarky5905

    3 ай бұрын

    @@baldchessmanNice, it's been a while since but do you have any pointers? Thinking of doing the same thing myself.

  • @baldchessman

    @baldchessman

    3 ай бұрын

    @@vansnarky5905 sure, the system I used there was an id system , each item has a different id and when saving I save an array of ints for the IDs and an array of ints for how many items each slot has For example: dirt id: 0 stone id : 1 If the first inventory slot has 3 dirt and the second slot has 4 stone I'd save IDs:[0,1] counts:[3,4] (Empty slots would be represented as -1 id) And when loading I go through the array of IDs and add the items back with the correct quantity , skipping over empty slots(IDs of -1)

  • @vansnarky5905

    @vansnarky5905

    3 ай бұрын

    @@baldchessman neat, thanks for the quick reply!

  • @baldchessman

    @baldchessman

    3 ай бұрын

    @@vansnarky5905 no problem, now go use it :D

  • @DrawMaster115
    @DrawMaster115 Жыл бұрын

    How would you adjust this system for a point and click solution instead of drag and drop?