- Home /
what does @CustomEditor do ?
hi,
I'm trying to build a CustomInspector. But i'm a little bit confused about the example script on unity script reference.
My questions are :
What does @CustomEditor do? Are there some tutorials for unitycustom examples ( can't find them)? What i have to do ,to modify my inspector?
I build some EditorWindow scripts ( these work) , but i want to have an inspector modification. Maybe you can help me. Thanks for Answers.
Answer by Molix · Jul 05, 2011 at 02:32 PM
To make a custom inspector, extend "Editor", and put the @CustomEditor attribute before the class declaration. The attribute tells Unity which class (e.g. which of your MonoBehaviours) that this Editor will work on.
It looks like there's an error in the doc link you sent. In the @CustomEditor attribute it should be the class you want to edit, not the class that you are defining below.
i.e. instead of:
@CustomEditor(MyPlayerEditor)
class MyPlayerEditor extends Editor {
it should be:
@CustomEditor(MyPlayer)
class MyPlayerEditor extends Editor {
Yeah, the example at http://unity3d.com/support/documentation/ScriptReference/CustomEditor.CustomEditor.html is a better one to refer to.
mhh k that helps. Finally i put the script in the standard assets to get a nice result.
Your answer
![](https://koobas.hobune.stream/wayback/20220612133238im_/https://answers.unity.com/themes/thub/images/avi.jpg)