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
1
Question by Alibaba994 · Jan 20, 2018 at 07:30 PM · inspectorcustom editorcustom-inspector

Can't get Custom Editor to display

I have followed several tutorial on setting up a custom editor for components in Unity but all result in nothing changing in Unity. Any ideas what I'm missing? Thanks!


File: Assets\Editor\PlanetControllerInspector.cs

 using UnityEditor;
 using UnityEngine;
 
 [CustomEditor(typeof(PlanetController))]
 public class PlanetControllerInspector : Editor {
 
     public override void OnInspectorGUI()
     {
         GUILayout.Label("TEST");
     }
 }
 



File: Assets\Scripts\PlanetController.cs

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlanetController : MonoBehaviour {
 
     public Camera Cam;
 
     public int MaxPlanetResolution = 3;
 
     public int QuadSize = 16;
 
     public int PlanetSize = 32;
 
     ....
 }
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
0

Answer by Backside2357 · Jan 20, 2018 at 08:52 PM

Your code works, what exactly are you doing?

Btw: Consider enclosing your whole class with the #if UNITY_EDITOR compiler tag (including the using UnityEditor !):

 #if UNITY_EDITOR
 using UnityEditor;
 
 [CustomEditor(typeof(TestScript))]
 public class TestScriptGUI : Editor {
 
 ...
 
 }
 #endif

Otherwise you will get a compiler error as soon as you try to build your project.

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 Alibaba994 · Jan 20, 2018 at 11:56 PM 0
Share

Added the compiler tags and the project builds still but the GUI never changes in the inspector :/

avatar image Backside2357 Alibaba994 · Jan 21, 2018 at 12:27 PM 0
Share

Well, it works for me and I do the following:

  • Create a new C# script called TestScript.cs

  • Create another new C# script called TestScriptGUI.cs

  • Edit the TestScriptGUI.cs and replace the code with this (which is basically exactly your code):


 using UnityEditor;
 using UnityEngine;
 
 [CustomEditor(typeof(TestScript))]
 public class TestScriptGUI : Editor {
 
     public override void OnInspectorGUI()
     {
         GUILayout.Label("TEST");
     }
 
 }

  • Drag the TestScript.cs on the Cube GameObject Inspector

  • The Inspector now shows "TEST"

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

127 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

Related Questions

Custom Editor: Array of Structs with elements hidden by toggles 0 Answers

Add multiple custom editors for same type of object. 0 Answers

Objects in Custom Editor Resetting on Play 1 Answer

How to create a selection menu in the inspector for classes and their methods? 1 Answer

How to select a MonoBehaviour in inspector from a cusom editor? 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