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 chirhotec · Sep 17, 2013 at 06:58 PM · eventcustom-inspectorcustom-editorkeyboardevent

Key Events in Hierarchy Window

I know its possible to detect key events when the inspector window is selected, using a custom editor. ie:

 using UnityEngine;
 using UnityEditor;
 using System.Collections;
 
 [CustomEditor(typeof(MyClass))]
 public class MyClassEditor: Editor
 {
     public override void OnInspectorGUI()
     {
         // Draw Default Inspector
         DrawDefaultInspector();
 
         // Respond to key presses
         if (Event.current.isKey)
         {
             Debug.Log("Key Pressed- lets do something!");
         }
     }
 }

But is there a way to do this when the Hiearchy Window is in focus?

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 sotirosn · Nov 21, 2013 at 09:31 PM

I don't think OnInspectorGUI captures events. And the hierarchy window is not the same as the inspector window so your title is wrong.

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 chirhotec · Nov 22, 2013 at 01:16 AM 0
Share

The title is correct, but maybe the question could have been worded more clearly?

The Inspector does capture keyboard events when its in focus. The code listed is an example of a custom inspector for the "$$anonymous$$yClass" $$anonymous$$onoBehavior that captures keyboard events. If you put the $$anonymous$$yClass script on an object, select the object, click on the inspector, and press a key, it will bring the statement to the debug log.

What I as asking is if there is a similar mechanism for doing this when selecting objects in the Hierarchy Window. So, for example, I could select an object from the hierarchy and press a key to do some custom logic on the event.

avatar image sotirosn · Nov 22, 2013 at 02:19 PM 0
Share

Hmm I need the same thing actually because I would like to respond to when objects are duplicated or copy/pasted. You can hook the inspector and scene view but I don't think the hierarchy. $$anonymous$$aybe you can derive the EditorWindow class and make your own hierarchy window?

avatar image chirhotec · Nov 22, 2013 at 05:04 PM 0
Share

This post might help you, though its not exactly what we're proposing here, as you still need to have the Inspector selected. http://forum.unity3d.com/threads/94007-Detecting-Copy-Paste-Duplicate-Events-on-Editor

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

16 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

Related Questions

How to force close Popup Window? 1 Answer

How do I change inspector values of other game objects using a custom Editor Window 0 Answers

Getting a target's gameobject in custom editor 1 Answer

Prefabs aren't saving with Undo.RecordObject 4 Answers

Inspector: custom property with custom type use default editor 3 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