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 keyp3r · Jan 13, 2019 at 10:07 PM · custom editorpropertydrawercustom inspector

Bool field in CustomPropertyDrawer isn't clickable?

I'm trying to use this function to draw a bool on a custom class of mine:

EditorGUI.PropertyField();

The bool is drawing just fine, and if I click on the label for the bool it'll highlight/select I can press Space to toggle the checkbox/bool, but I can't click on the checkbox itself.

No other inspector GUI stuff I'm doing has this issue.

It almost seems like the checkbox part of the field is outside the hitbox of the field? Anyone got anything on this? Thanks in advance!

Comment
Add comment · Show 1
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 troien · Jan 14, 2019 at 11:27 AM 0
Share

Without any code example of what you do that resluts in the thing you describe, I'm afraid that all we can do is guess. So here is my guess ;)


Could it be that you have another (perhaps invisible) component drawn on top? (Or at least another component/rect that can receive your click input)? (Either in the custompropertydrawer or a custom inspector in which 1 or multiple of those properties are drawn).

You could try logging the values of GUIUtility.hotControl and GUIUtility.keyboardControl to see if you can find anything odd there specific to this property.

Also, in case you are not actually working inside a custompropertydrawer where you already have a rect you can use, you could try to use EditorGUILayout.PropertyField() ins$$anonymous$$d. As this class is usefull for when you want to make it look like the rest of the UnityEditor, and Unity takes care of the layout, which requires less code :) and reduces the chance that you have 2 overlapping rectangles that can consume input.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by svendkiloo · Jun 25, 2019 at 09:34 AM

EDIT: Sorry, I only just realised the bit about you being able to toggle the value with space, so I guess the issue isn't the one I describe/solve below. However, it might be worth leaving the answer on here, as it's still relevant to some people (like me) who can't get the bool field to work.


Like @troien mentions, without code we can only guess :) However, I have a different guess, as I experienced the same issue.

If your code looks a bit like this:

 EditorGUI.Toggle(rect, isSelected.boolValue);

This would not update the value of isSelected.boolValue, as the Toggle method returns the new value, rather than write to the parameter (it's passed as value, rather than ref). So you just need to change it to:

 isSelected.boolValue = EditorGUI.Toggle(rect, isSelected.boolValue);



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 Bunny83 · Jun 25, 2019 at 09:44 AM 2
Share

He used EditorGUI.PropertyField, at least that's what he said. PropertyField works on SerializedProperties and does update the value automatically through the SerializedProperty.


As he sea$$anonymous$$gly can actually change the value by pressing space, the assignment can't be an issue.


$$anonymous$$y guess would also be either some overlapping controls so another control "eats" the click event or some other control messes with the hotControl for some reason. Though this $$anonymous$$imalistic question can't be answered.

avatar image
1

Answer by nmhild_RP · Jan 14, 2021 at 04:45 AM

If anyone stumbles across this thread, scratching their heads, don't forget to put

 serializedObject.ApplyModifiedProperties();

at the bottom of the OnInspectorGUI() method.

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 s4relok · Apr 23, 2021 at 07:55 AM 0
Share

It did the trick!

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

102 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

Related Questions

EditorGUILayout.PropertyField cannot draw custom class? 2 Answers

Inspector Overlapping Text Label at a Position 1 Answer

CustomPropertyDrawer undoable properties 1 Answer

SerializedObject.FindProperty returning null 2 Answers

Adding dropdown to a list add buttom 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