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
1
Question by sonicether · Feb 10, 2015 at 02:19 AM · editor-scriptingeditorguicustom-inspectorguistyle

How to achieve proper inspector functionality (blue highlight of last tweaked) with elements from the GUI class (not from EditorGUI)

So, I'm working on a custom inspector that uses GUI.HorizontalSlider rather than EditorGUI.Slider because I need more control with the exact positioning of the horizontal slider itself and the look of the slider using custom GUIStyles.

Everything is working great except for one thing. When tweaking any slider or EditorGUI property, it is highlighted and somehow tagged as active (with a blue highlight/outline). This functionality does not work with GUI elements from the GUI class in the inspector. This causes problems when tweaking my slider. Any previously tweaked element stays highlighted, even after tweaking my slider. I've got an EditorGUI.FloatField setup to edit the same value as the slider, and when clicking on the float field to adjust the value, and then moving the slider, the numbers in the float field don't change properly, and they stay highlighted as if still editing them.

I've tried wrapping my GUI.HorizontalSlider with EditorGUI.BeginProperty() and EditorGUI.EndProperty() but this doesn't solve this problem.

Is there anything in the API that would allow me to take control of this mysterious blue highlighting of the last tweaked GUI element in the inspector? If I could somehow force it to happen, this would solve my problems. I would like to not have to resort to using EditorGUI.Slider because I need to know the exact Rect that corresponds to the horizontal slider itself (due to some skinning magic), and using EditorGUI.Slider adds a float field and a label.

Any help would be greatly appreciated.

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
3
Best Answer

Answer by sonicether · Feb 11, 2015 at 08:46 AM

Alright, I found a solution. I figured I'd post it here in case anyone googling the problem lands on this page.

Setting focus (blue highlighted control is "focused") of a control is done with GUI.FocusControl(). If you look at the method signature in the docs, you'll see it uses a control name to determine which control to focus. So, you need to name your GUI control with GUI.SetNextControlName() before it's created.

I simply check to see if the slider was adjusted with EditorGUI.BeginChangeCheck() and EditorGUI.EndChangeCheck(), and if it was, I focus the control with GUI.FocusControl being sure to provide the control's name.

Comment
Add comment · 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

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

2 People are following this question.

avatar image avatar image

Related Questions

Custom inspector variable resets automatically 1 Answer

Custom inspector: changing foldout's text color 3 Answers

How to force close Popup Window? 1 Answer

Accessing All Selected Objects in OnSceneGUI 1 Answer

EditorGUI.Foldout consumes click so GUI.Button doesnt work when inside of foldout region. 1 Answer


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