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
0
Question by remy_rm · Nov 16, 2018 at 06:19 PM · inspectoroninspectorgui

OnInspectorGUI not working

I am trying to draw a button to a custom editor so i can call a function by clicking a button.

currently my script looks like this:: using UnityEngine; using UnityEditor;

 [CustomEditor(typeof(TerrainManager))]
 public class BuildButton : Editor
 {
     public override void OnInspectorGUI()
     {
         DrawDefaultInspector();
 
         TerrainManager builder = (TerrainManager)FindObjectOfType(typeof(TerrainManager));
         if (GUILayout.Button("Generate Grid"))
         {
             builder.GenerateTerrain();
         }
 
         if (GUILayout.Button("Clear Grid"))
         {
             builder.ClearTerrain();
         }
     }
 }
 

But it returns the error: OnInspectorGUI()' is marked as an override but no suitable method found to override. I have the script in an "Editor" folder as that is required for Editor scripts.

I know i'm supposed to do it like this as i've used it before in other projects, and pasting this code in a clean project also does what i want.

Anyone has any ideas why it may not work currently?

I'm using unity version 2018.3.0f3 on windows

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 Tomer-Barkan · Nov 16, 2018 at 06:29 PM

I happen to be using the exact same version and copy-pasted your code as is, only changed TerrainManager to Button, and it works perfectly.

Did you copy-paste your code? Did you change anything? The only thing I can think of is that you may have another class named Editor somewhere in the project, and it inherits that instead of the builting unity editor class.

Comment
Add comment · Show 2 · 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 remy_rm · Nov 16, 2018 at 06:48 PM 1
Share

It turned out to be that an asset i had downloaded (But wasn't even using) indeed had a class named "Editor" that was overwriting the built-in Unity editor class.

Thanks for the reply!

avatar image AldeRoberge · Jan 07, 2020 at 01:47 AM 0
Share

Logged in just to say thank you! Could have never figured it out.

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

98 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

Related Questions

Using a CustomEditor in the inspector and also seeing normal inspector fields 1 Answer

How do you force a custom inspector to redraw? 7 Answers

Is there a way to draw on the scene view from an asset being inspected by the Inspector? 0 Answers

Callback when custom PropertyAttribute changes 0 Answers

OnInspectorGUI Custom Drawing? 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