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 /
  • Help Room /
avatar image
0
Question by helenaudd · Feb 21, 2017 at 01:12 PM · uieditorbuttoninspectorcustomeditor

Custom UnityEngine.UI button inspector

I have implemented a button on my own, which inherits from UnityEngine.UI.Button, and it has its own custom inspector.

 public class TwoStateButton : Button
 {
     ...
 }

 [CustomEditor(typeof(TwoStateButton))]
 public class TwoStateButtonEditor : Editor
 {
     public override void OnInspectorGUI()
     {
         base.OnInspectorGUI();
     }

     ...
 }

I have an issue where the behaviour of the Transition mode settings in the Button inspector is not working properly for my class TwoStateButton as long as I have a custom editor.

The Button inspector looks like this, and so does the TwoStateButton inspector if I delete or comment out the custom editor class.

But my custom inspector looks like this, despite me not making any changes to the inspector.

So basically, the behaviour with what fields are visible changes depending on the Transition mode is lost, and all settings are always shown.

I have tried exchanging base.OnInspectorGUI(); with DrawDefaultInspector(); but it had no effect. I have tried importing the UnityEditor.UI library and making my TwoStateButtonEditor inherit from ButtonEditor instead of Editor, but it had no effect.

Is there a way to make a custom editor, but still keep the Transition mode settings behaviour?

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 Adam-Mechtley · Feb 21, 2017 at 01:18 PM

Hi! Please see my answer here. Your custom editor needs to subclass ButtonEditor, not Editor.

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 helenaudd · Feb 22, 2017 at 02:54 PM 0
Share

I did try that before, and as described, that had no effect. But I must have done something wrong, because that did now solve my problem. Thank you!

avatar image Adam-Mechtley helenaudd · Feb 22, 2017 at 03:08 PM 1
Share

$$anonymous$$y guess is you had inherited ButtonEditor, but called DrawDefaultInspector() ins$$anonymous$$d of base.OnInspectorGUI() (as in the thread I linked).

avatar image helenaudd Adam-Mechtley · Feb 24, 2017 at 11:59 AM 0
Share

That is probably it. Awesome, thanks!

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

143 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 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

How can I detect when the name of a gameobject has been changed in the editor and do something when that happens? 2 Answers

button click() requires 2 clicks to work 1 Answer

Codeless IAP causing inspector bug 0 Answers

unity 2018.3.12f1 Button OnClick call function on another instance? of script 0 Answers

Button not interactable but still responding to events. How do you fix this? 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