[Unity] Custom Editor for Unity

Scissor Lee
Akatsuki Taiwan Technology
2 min readMay 31, 2019

[Overview]

  1. Decompile UnityEditor.dll by ILSpy
  2. Find default editor class name:GameObjectInspector
  3. DecoratorEditor
  4. Example: Apply button for new nested prefab system

[Decompile UnityEditor.dll by ILSpy]

Download ILSpy for Mac
https://github.com/icsharpcode/ILSpy

Find your UnityEditor.dll

Decompile UnityEditor.dll

mono ILSpyMac.exe -n Decompiled ../UnityEditor_2018_4

[Find default editor class name]

Search all decompiled files by the target component. Ex: GameObject

CustomEditor(typeof(GameObject))

Then you’ll find the default editor name for GameObject is GameObjectInspector

[DecoratorEditor]

Then you’ll need this class to start customizing your editor.
DecoratorEditor.cs
https://gist.github.com/liortal53/352fda2d01d339306e03

Created by Lior Tal
http://www.li0rtal.com/extending-unity-inspectors/

The main concept use Decorator Pattern.
The decorator implements all public inspector methods, delegating them to the decorated instance internally.

[Example: Apply button for new nested prefab system]

GameObjectEditor “decorates” GameObjectInspector by inherited from DecoratorEditor

--

--