Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
2
Question by LukaKotar · Dec 18, 2015 at 04:49 AM · editorwindoweditorguieditorguilayout

Create a greyed out value field in the editor?

I am writing an editor window to help me automate some tasks. Basically, in some cases I want to create a greyed out (non-interactive) field instead of the regular one, if changing the value doesn't make sense.

Here's an example from the Unity preferences window: example

I could not find any clues online, but I imagine it can be done in a custom window as well. Any clues?

screenshot-2015-12-18-053845.png (8.7 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by LukaKotar · Dec 23, 2015 at 12:27 AM

I was able to find the answer. Basically, set GUI.enabled to false, and then back to true after displaying the field(s).

 GUI.enabled = false;
 // Your greyed out GUI
 GUI.enabled = true;

Comment
Add comment · Show 1 · 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 Rewq773 · Jul 01, 2018 at 09:35 PM 1
Share

Another solution:

 [CustomEditor(typeof($$anonymous$$yScript))]
 public class $$anonymous$$yScriptEditor : Editor
 {
     public override void OnInspectorGUI()
     {
         collider.enabled = EditorGUILayout.BeginToggleGroup("Enable Collider", collider.enabled);
         // Your greyed out GUI
         EditorGUILayout.EndToggleGroup();
     }
 }


avatar image
4

Answer by PROE_ · Jan 02, 2020 at 09:54 PM

For others, probably the best solution is EditorGUI.BeginDisabledGroup(bool)

Comment
Add comment · Show 4 · 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 calebw2370 · Mar 12, 2020 at 11:03 PM 0
Share

When I use that is says the name EditorGUI.BeginDisabledGroup does not exist in the current context. ?

avatar image Bunny83 calebw2370 · Mar 14, 2020 at 01:05 AM 0
Share

Then you're doing something wrong. Are you sure that you actually try to use this in an editor script and that you have a using UnityEditor; at the top of your script? Note that this does not work in a runtime script. The UnityEditor namespace does only work for editor scripts.

According to the documentation EditorGUI.BeginDisabledGroup and the corresponding EditorGUI.EndDisabledGroup are still there.

avatar image calebw2370 · Mar 14, 2020 at 01:37 AM 0
Share

How do you make a script an editor script and not a runtime script?

avatar image eMsylf calebw2370 · Jan 11, 2021 at 11:53 AM 0
Share

There's this tutorial in the docs that should get you on track: https://docs.unity3d.com/$$anonymous$$anual/editor-CustomEditors.html

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

37 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

Related Questions

GUİ Editor Window input 0 Answers

Editor Int sliders affecting each other 0 Answers

Custom EditorWindow indicator 0 Answers

Making a custom editor window much like the Animator window? 0 Answers

EditorWindow fields are too far away from each other 0 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