Custom Editor for Button/Text etc. ?

Not Working? Why?

[CustomEditor(typeof(Button))]
public class ButtonOverride : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUILayout.HelpBox(“Hello”, MessageType.Info);
}
}

The Button component has it’s own editor, i think that it is loaded after your own code is being loaded, so it is effectively overriding your custom editor.

Here’s a cool hack (just tested this): place the same code you posted as a compiled DLL.

The original editor for Button is defined in UnityEditor.UI.dll, so you should create your DLL with a name that will be processed after that (i assume the libraries are processed in alphabetical order).

I made a DLL called ZEditor.dll and placed it under Assets/Editor and it worked fine :slight_smile:

Not ideal, since nobody guarantees anything about the order that these are processed, but this seems to work fine.

What is this mean.Are you know?
2292964--154245--upload_2015-9-13_0-0-7.png
2292964--154244--upload_2015-9-12_23-59-12.png

If you create a new library, you should add the Unity DLLs as references (UnityEngine.dll, UnityEditor.dll are the bare minimum)

I forgot the unityengine.dll

Yes.it worked : D Thanks.Have a nice day!
2292976--154247--upload_2015-9-13_0-20-54.png

1 Like