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
3
Question by Suguma · Jul 01, 2015 at 09:52 AM · drageventeventsystemdrag-and-dropevent triggering

Initiating a Drag event by code

Hi,

I have this object (a regular game object) which I'm currently able to drag around using the EventSystem. I implemented the BeginDrag, Drag and EndDrag interfaces and stuff. All working fine.

The thing is this object is instantiated when a certain button is clicked. I want the user to press the button and instantly have the object dragging with the mouse without having to click it again to trigger the drag events. I tried ExecuteEvents.Execute, but, althought it does trigger the event I tell it to, it does not trigger following events. In other words, even though I can call OnDrag or OnBeginDrag, these methods will be called once and that's it, they won't make the OnDrag event keep on happening, because the object isn't being dragged at all.

So basically I want to start dragging my game object when I click a button. Can anybody help?

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 helenaudd · Jan 26, 2017 at 03:07 PM 0
Share

@$$anonymous$$uma Were you ever able to solve this? I'm in the same situation.

avatar image Suguma helenaudd · Jan 26, 2017 at 03:19 PM 0
Share

Wow, it's been a long time

I don't remember exactly how I solved it, sorry, but I have two solutions I can think of:

  1. You could try to keep your button detecting events and send them to the object you want to drag. If you don't raise your finger, the button will receive all the events event if your finger is not over it anymore.

  2. You could create some sort of InputController that will track Input.$$anonymous$$ouseDown, $$anonymous$$ouseUp, etc, raycast for objects and everything. The UI button would then instantiate the object and pass it on to the InputController, which would drag the object without using Events

Hope it helps!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

IPointerClickHandler works until I add IPointerDownHandler 0 Answers

Issues implementing UI event triggers via script 1 Answer

On Void Called 2 Answers

Hide/show UI Button and trigger the OnPointerDown event ?! 0 Answers

How to drag gameobjects (other than ui elements) using the event trigger? 2 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