Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by WhipJr · Aug 02, 2017 at 01:48 AM · inputeditor-scriptingcustom

adding input combinations to a custom editor script?

Basically, I am trying to add in a 'Ctrl + Scrollwheel' input to change a variable up for a positive scroll or down for a negative scroll in an editor script that i am creating.

What is the best way to approach this input combination for the editor?

Everything i have looked up mostly refers to adding a Ctrl activation to a menu item and this is not what i am looking for.

~EDIT~

Upon further searching, i have stumbled upon code references that may be useful, but i can't seem to get them to work to do what i need. There is a bool variable named 'modifier' declared with the other variables as well one called inc which i am using to try and limit the scroll wheel to only one call per scroll.

 Event e = Event.current;
 
     if (e.isScrollWheel && e.control) {
         if (e.delta.y == 3 && inc)
         {
                 Debug.Log(e.delta.y);
                 selectedPrefabNum -= 1;
             inc = false;
         }
         else if (e.delta.y == -3 && inc)
         {
                 Debug.Log(e.delta.y);
                 selectedPrefabNum += 1;
             inc = false;
         }
     }
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
1
Best Answer

Answer by Bunny83 · Aug 02, 2017 at 05:45 AM

The Event class always hold the state of the 3 modifier keys: alt, control and shift.

So there's no need to track the modifier state yourself. However if you do, you have to react to the KeyDown and KeyUp events

 switch (e.type)
 {
     case EventType.KeyDown:
         {
             if (Event.current.keyCode == KeyCode.LeftControl)
                 modifier = true;
         }
         break;
     case EventType.KeyUp:
         {
             if (Event.current.keyCode == KeyCode.LeftControl)
                 modifier = false;
         }
         break;
     // ...

Comment
Add comment · Show 3 · 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 WhipJr · Aug 02, 2017 at 12:52 PM 0
Share

i fixed this, but im noticing i can only get the event to fire once ive clicked on my window of the extension. is there any way to track the events globally? or at least when im in the editor? and on top of that, my scrolling is still not being detected using delta it seems.

avatar image Bunny83 WhipJr · Aug 02, 2017 at 02:27 PM 0
Share

Events are generally send to the active window. If you focus another window, that window will receive all events. There is no real solution to get events globally. It also wouldn't make much sense. All user interactions are always context specific. If you want to react to events in the SceneView, you can subscribe a callback to the "SceneView.onSceneGUIDelegate". If you need to react to events in the inspector that can only be done from an active custom inspector.

$$anonymous$$eep in $$anonymous$$d that the scrollwheel is used for many other things as well. Reacting globally to such an event wouldn't make much sense. For example the animation editor window uses Shift-scroll and Control-scroll for scaling horizontally / vertically.

avatar image WhipJr Bunny83 · Aug 02, 2017 at 02:39 PM 0
Share

yeah i was going to add the alt modifier to my scroll so its Ctrl+Alt+Scroll to avoid most of the scrolling inputs, but i mainly need it in the scene view. I'm creating the ability to scroll through the currently loaded assets to switch between them instantly. I'm looking into the SceneView.onSceneGUIDelegate, thank you. once i know this is what I'm looking for, ill accept your answer :)

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

85 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

Related Questions

Removing Inputs from the Input list 1 Answer

Detect input from EditorApplication.update callback? 1 Answer

How to detect if project is Using new or Old Input System via code? 1 Answer

Override scene view grid with my own? 0 Answers

Make custom input devices available to scripting via "Input" 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