- Home /
Unity 5 CustomEditor for Folders
In Unity 4.6.x it was possible to override the way a folder is displayed by writing a CustomEditor for UnityEngine.Object like shown in this Unite-Presentation: https://www.youtube.com/v/SyR4OYZpVqQ?version=3&f=playlists≈p=youtube_gdata (starts at 16:17 mins). For those wondering, Buttons and stuff only worked in the OnHeaderGUI(), but not in the OnInspectorGUI() where they were displayed but inaccessible.
Now that I switched from Unity 4.6 to 5.0, the Folders seem to have changed type (they are of type AssetImporter now). On top of that the OnHeaderGUI() and OnInspectorGUI() do not seem to get called at all any more, whereas the OnEnable() and OnDisable() callbacks still work (That's how I found out about the type change).
Does anyone know a way to get CustomEditors for Folders (fully) working again?
Answer by RudyTheDev · Mar 05, 2015 at 06:47 PM
Folders react to [CustomEditor(typeof(DefaultAsset))]
.
Apparently Unity5 ignores the true
part of [CustomEditor(typeof(Object), true)]
even though DefaultAsset:Object
. Thankfully, folders seem to be DefaultAsset
, so [CustomEditor(typeof(DefaultAsset))]
actually works to receive the OnHeaderGUI()
and OnInspectorGUI()
callbacks. OnInspectorGUI()
comes pre-disabled, but can be GUI.enabled = true;
.
Other assets seem to behave the same way. I cannot get C# scripts to show up for [CustomEditor(typeof(TextAsset), true)]
(`MonoScript:TextAsset`), but I can for [CustomEditor(typeof(MonoScript))]
. (Going from this, I looked at all classes deriving Object
and guessed DefaultAsset
.) I guess you have to know the concrete type of your asset to do custom editors for assets.
P.S. I too thought they would be AssetImporter
-derived or something, but they don't seem to be. AssetImporter
stuff uses internal AssetImporterInspector
to draw.
Your answer
Follow this Question
Related Questions
Trying to create Custom Inspector Labels and I get erros 0 Answers
Building Plugins only for editor 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Custom Inspector to Load Instance Values 0 Answers