• 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 Vincenzo Albery · Jul 12, 2010 at 09:11 AM · drag-and-drop

Drap & Drop Object to Scene

Hello Everyone,

I have a problem about the drag & drop objects from my gui to game area... I have a gui and objects in my gui... I want drag&drop this objects to my area?

I need an example or tutorial how can i make that in Unity.

Can you help me ?

Comment
Add comment · Show 1
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 cncguy · Jul 12, 2010 at 10:21 AM 0
Share

Do I understand correctly that you have some sort of inventory in your GUI with icons of objects that you want to drag into your game and instantiate as gameobjects?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by cncguy · Jul 12, 2010 at 10:36 AM

I think I understand what you are saying. You are displaying items in your GUI as icons and want to drag them into your game as gameobjects. If this is the case can I suggest you initially implent this as GUI buttons. The image of the button is the image of the item. When you click the button instantiate the item as a game object don't worry initially where you instantiate it, just make it is somewhere you can see it - experiment. You can check out the unity script documentation for GUI.Button and Instantiate and this will give you enough to make this happen.

Once you have done that look at how the button is drawn and think about how you could move where it is drawn using Input.MousePosition again check this out in the scripting manual.

Once you have done that, work on where in your scene you want the object to be instantiated. You can use something like Camera.main.ScreenToWorldPoint(use mouseposition here) to get the position to create the object.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

drag rigidbodies script 1 Answer

click and drag above y coordinate 7 0 Answers

Click and Drag - How to? 2 Answers

how can i drag and drop a box of type text? 0 Answers

RigidBody2d not detecting collision when dragged 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