Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Breaking_Reality · Aug 15, 2018 at 08:46 PM · collisionuiinventory

Best way of doing inventory in UI

Hey! Is it ok to use collision boxes in UI to check if one item is on top of another item? (Inventory system) Or is there another way to check if an item is on top of another item in UI. I want to know the best way of doing this because it's an inventory system and I don't want an inventory system taking up computer juice if ya know what I mean haha

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image eses · Aug 16, 2018 at 09:24 AM 0
Share

@Breaking_Reality - Hi - to me it sounds like you haven't done even the basic research into topic.


If you google for it, you come across multiple tutorials, youtube is full of them. None of these will give you fully working system (probably) but will $$anonymous$$ch you the basics what and how you should do. I've been learning how to create inventory system, it will boil down to how you'll manage your events and related things - are you just going to use clicks to add/remove items, or maybe drag and drop, and are you going to also drag world items to inventory and so on. $$anonymous$$aybe you'll allow stacking of items, or swapping items from slot to slot... Depending on these, you'll have to consider different UI system, event system and raycasting related issues.

Also, Unity manual has an example of drag'n'drop using UI system, although I find it pretty convoluted for an example.

Unity UI system scripts you create, can implement UI events, Like BeginDrag, PointerEnter and so on - these might be little hard to find at first, but there are many posts on these, now that you know what to search for: https://docs.unity3d.com/ScriptReference/EventSystems.EventTriggerType.html

avatar image Breaking_Reality eses · Aug 17, 2018 at 01:31 AM 0
Share

@eses Actually I spent 2 days looking for the best way of doing it for my games inventory. Collisions is something I wanted to avoid and I found the IDrag extensions but I was still struggling on how to know if the mouse was over some parts of UI. I used the eventsystem pointer things you mentioned but I didn't know how to write it properly I started with something like this one line of code EventSystem.current.RaycastAll() with some random parameters and well it didnt work. I gave up on it because I didn't find Great documentation and examples on it online. Then I found someone on some janky website who managed to get it right using evensytem and raycasting. I used that and it worked. With like 8 lines of code it returned a list of were the mouse was at. Then I just needed to get the IDragHandler, IEndDragHandler in the code and walla I got it to work when I wanted it too. The next issue was knowing what slot had what and creating things like if that slot had an item alreay that ment the user wanted to switch the items slots. I written this who thing and it worked but it was messy and some things didnt work exactly how I wanted with some random bugs in it too. I was forced to re - do the inventory code 3 times and now I finally got something I REALLY LI$$anonymous$$$$anonymous$$ Since Im new the other tries were messing with code all over the place. I decided I should have a hotbar manager and Drag/Drop code on the UI elements and the hotbar manager would add/remove/switch the items the user is dragging/dropping around in their inventory and I also have a Inventory $$anonymous$$anager and a HotbarSlot scrip that goes on all the hotbars so that I can just call the inventory manager and ask for an item in hotbar slot 1 etc or remove an item in hotbar slot 9 etc. I decided not to go on youtube because I felt like I needed to learn it by reading online and just experimenting. Though it took 4 days in total I got it working very nice and I accomplished doing it myself with a little reading and poking around in threads online. Thank you for your help but you are a little too late. Now I know looking on youtube might save me alot of time and I shouldnt be ignoring these great sources that can help me alot. I guess I did this because I wanted to actually learn and not forget something all the time like I would if I watched a youtube video. I'm afraid I do too much of it sometimes. Thank you though and I will mark you as best answer because you explained everything I did in my code.. just a little too late for me haha!

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

256 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

One textUI and two colliders that update it 0 Answers

Particle System Collision with UI 0 Answers

How can I create a VR world space touch-screen input system? 0 Answers

Display list as UI or GUI 0 Answers

Why is drag and drop not working? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges