Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by moriam · Oct 01, 2014 at 09:46 AM · 2dinventorydrag-and-drop

Design a drag and drop inventory with transition from icons to game objects

Hi,

I’m trying to write a simple 2d game where the user can drag and drop different objects on the screen. Each of these objects is made from a Prefab i’ve created with a Drag and Drop component (which handles events like mouse_drag, mouse_down etc’). There is an inventory on the side of the screen with scaled images from where the user can drag the different objects to the game screen (after that he can continue to drag these objects. Thats why Iv’e written the drag & drop functionality in the object’s class and not in the inventory’s class). I’m having a little bit of trouble understanding how I should implement it:

The first thing i’ve tried was to show only icons for the different objects in the inventory and then, when they were clicked and dragged, attach the actual game object to the mouse. But that didn’t go so well because i couldn’t really understand how to set the game object in the correct place and then use its drag and drop component to drag it around.

The second thing i was planning to do was to put the actual prefabs (my game objects) in the inventory (maybe scaled down a bit) and then they can give their own drag and drop functionality..

I would really appreciate some guidelines or opinions about the design because I feel i’m doing things kinda wrong.. What do you think?

Thank you, Moria.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Willkuerlich · Oct 21, 2014 at 02:54 AM

Hey, You propably want a base slot class, which holds basic slot information like the actual sprite, a text with the amount or a description etc.. with a type enum. Then you could inherit from that class with a version of dragable slots, for example like in a loot window, and another version of dropable slots which can only recieve one way or two way, depending on the using case or time. the base class can be serialized data or prefab, your inventory is basically an array of the base class. What you think? I'm myself working right now on an InventorySystem, so suggestions are welcome ;)

P.S. perhaps this can help you for inpiration or code: http://forum.unity3d.com/threads/ui-example-project.263418/

Comment
Add comment · Share
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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to make a drag-drop grid-list of prefabs using custom editor? (to make a tool for game designers) 0 Answers

Hover over text VERY glitchy 0 Answers

Drag and Drop w/ Snapping 0 Answers

Method only Activates when an item is dragged on it 0 Answers

Custom Editor: How to get a reference to an existing object in the scene at the mouse position after drag-and-dropping a prefab into the scene? 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