• 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 unity_DQzS_dvHKTXADw · May 24 at 12:21 PM · inputeditor-scriptingeventdrag-and-drop

[Editor] Get Scroll Wheel while dragging

Hi, I'm creating a custom editor window in which you can drag and drop specifics prefabs in the scene view. I've added a snap system on top of it and everything works fine at this point. What I'd like to do now is to allow prefab rotation while dragging, using the mouse scroll wheel, but no madder what I've tried I can't get the scroll wheel value. I'm not familiar with Events, and I think that why I'm struggling. Here is the code i'm using :

  private void DuringSceneGui()
             {
                 if (_IsDragging)
                 {
                     if (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform)
                     {
                         if (_draggedClone == null)
                             _draggedClone = (GameObject)UnityEngine.Object.Instantiate(DragAndDrop.objectReferences[0]);
 
                         DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                         Vector3 mousePos = Event.current.mousePosition;
                         mousePos.y = SceneView.lastActiveSceneView.camera.pixelHeight - mousePos.y;
                         RaycastHit hit;
                         Ray ray = SceneView.lastActiveSceneView.camera.ScreenPointToRay(mousePos);
 
                         if (Physics.Raycast(ray, out hit))
                         {
                             if (FG_Processor.TagIsValid(hit.transform.tag))
                             {
                                 Selection.activeGameObject = hit.collider.gameObject;
                                 _draggedClone.transform.position = hit.collider.transform.position;
                             }
                             else
                             {
                                 Selection.activeGameObject = null;
                                 if (_draggedClone != null)
                                     DestroyImmediate(_draggedClone);
                             }
                         }
                         else
                         {
                             if (_draggedClone != null)
                                 DestroyImmediate(_draggedClone);
                         }
                         Event.current.Use();
                     }
                     if (Event.current.type == EventType.DragExited)
                     {
                         Debug.Log("Drag Exit");
                         _IsDragging = false;
                         _draggedClone.GetComponent<Collider>().enabled = true;
                     }
 
                 }
             }


So I've tried several types of approach, first the classic input way :

if (Input.GetAxis("Mouse ScrollWheel") != 0) { Debug.Log(Input.GetAxis("Mouse ScrollWheel")); }

and then, the event way :

if(Event.current.type == EventType.ScrollWheel) { Debug.Log(Event.current.delta); }

In both case, nothing came out while calling them in the isDragging if statement. Did I miss something obvious ?

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

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

180 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

Related Questions

Override Editor Controls 1 Answer

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

keyboard event "none" works as "enter" 0 Answers

Change pointerDrag target during a drag 2 Answers

Why is this script showing all keycodes except shift? 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