• 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
3
Question by DonHaul · Sep 20, 2017 at 05:50 PM · editoreditor-scriptingcustomeditoreditorscript

'CustomEditor' is not a attribute class

Hi there, I am on unity version 2017.1.0.f3 and for some reason an error that was not happening before, now occurs, and I didn't even change the editor script nor the Graphic script, anyone knows what might be causing, the - 'CustomEditor' is not a attribute class - to trigger?

that occurs in the line where is says

 [CustomEditor(typeof(Graphic))]


this is the beginning of that script:

 #if UNITY_EDITOR
 
 using UnityEngine;
 using System.Collections;
 using UnityEditor;
 
 [CustomEditor(typeof(Graphic))]
 public class GraphicEditor : Editor {
 

Any help would be appreciated :)

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 CraigGraff · Sep 20, 2017 at 11:25 PM 0
Share

Your editor script should be in a folder called Editor (and so won't need the "#if UNITY_EDITOR" -- though it also won't hurt anything).

DId you move the script to another folder or rename the Editor folder?

1 Reply

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

Answer by Bunny83 · Sep 20, 2017 at 11:47 PM

You most likely created a class with the name "CustomEditor" which hides the class "UnityEditor.CustomEditor".

The best and recommended solution is to rename your own class to something else. However if you want to keep that class you have to use the fully qualified name:

 [UnityEditor.CustomEditor( typeof(Graphic) )]
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 DonHaul · Sep 20, 2017 at 11:56 PM 0
Share

Thanks alot man! I had added alot of assets, from the assetstore and that created that class

<3

avatar image Bunny83 DonHaul · Sep 21, 2017 at 12:46 AM 0
Share

As i thought -.-

And that's why you should use namespaces, especially when you create assets for the assetstore. The only point of namespaces is to avoid name collisions. As long as the file where you need the CustomEditor attribute doesn't need anything from that custom namespace the problem would be already solved.

 namespace $$anonymous$$y.Awesome.Subnamespace
 {
     public class CustomEditor
     {
     }
 }
 
 namespace Another.Completely.Different.Namespace
 {
     public class CustomEditor
     {
     }
 }

This would be perfectly fine. Your project would now have 3 completely different classes with the name "CustomEditor" which have nothing to do with each other. If something is in a namespace you need to explicitly use a "using" statement to bring the classes in that namespace into the file scope. However if a class is declared in the global namespace you can't make it "disappear" since the global namespace is, well, globally available.

To be actually 100% sure to use the right class you would use:

 global::UnityEditor.CustomEditor

In case some crazy person created a class with the name "UnityEditor" or created a sub namespace called "UnityEditor" in which case this is the only way to actually reach the correct namespace. For more information see the microsoft docs

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

99 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

Related Questions

How to use an Editor script? 0 Answers

Draw inspector of array elements? 1 Answer

Give an specific parameter of my GameObject to a Script using the Inspector 1 Answer

Better Unity Event UI 0 Answers

Recreate default editor look manually without base.OnInspectorGUI [UnityEditor] 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