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 dreal · Jan 19, 2011 at 05:39 PM · gameobjectgrid2d-gameplaydrag-and-dropgui.button

GUI Buttons and game objects?

Is it possible to drag a game Object into or onto a GUI button which the GUI buttons act as a grid for an example? And the game object locks onto the GUI button like the drag and drop functionality in flash?

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 Jesse Anders · Jan 19, 2011 at 09:23 PM

Sure it's possible. (Game objects and GUI controls reside in different spaces, so you'll need to define specifically what the desired behavior is, but yes, whatever it is you're wanting to do, it's possible.)

Comment
Add comment · Show 4 · 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
avatar image dreal · Jan 22, 2011 at 08:14 PM 0
Share

I am having trouble trying to relate the GUI buttons with the game objects. I have a grid of 25 x 14 buttons which i need to drag and drop game objects in. I have the objects dragging and going back to its original position but i need them to stick to where the buttons are. Any suggestions?

avatar image Jesse Anders · Jan 23, 2011 at 08:51 AM 0
Share

Here's a hint: Check out the various Camera functions, such as WorldToScreenPoint() and ScreenToWorldPoint(). (These will help you get the positions of the in-game objects and the GUI controls into the same space.)

avatar image dreal · Jan 27, 2011 at 07:05 AM 0
Share

$$anonymous$$y thing is i know how to get the position of the gameobject, but how do i get the position of a grid of buttons that each have there own position using the Worldtoscreenpoint() and ScreenToworldPoint()? Please can you give me a way to implement this?

avatar image Jesse Anders · Jan 27, 2011 at 08:06 AM 0
Share

$$anonymous$$aybe someone else will provide a more detailed reply, but in short, if you use the GUI functions and specify the rects for the controls, then you already know where they are in screen space. You can then use WorldToScreenPoint() to get the object position into screen/GUI space (you might have to subtract the y value from the screen height - I can't remember for sure), and check to see if the point is in any of the control rectangles.

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

No one has followed this question yet.

Related Questions

Grid Layout Group leaking outside canvas. 1 Answer

when i add a gameobject it is way off grid? 1 Answer

How to apply more than one trigger on a single gamebject 1 Answer

How to Place and arrange 3D cards using Grid and Bounds 0 Answers

How to drag and drop any object to any empty space? 0 Answers


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