Compound custom inspectors for sub classes
I have a class called "GameItem" and a subclass called "WeaponItem" Both of them have custom inspectors and allow me to edit anything specific to that class. However, I'd like the subclass "WeaponItem" to also render the custom inspector elements from the superclass "GameItem" at the same time as the sub-item's custom inspector when it's selected.. However I don't know how to do this.
I can get this to work to show the default inspector for "GameItem" at the same time as the custom inspector for "WeaponItem", but not custom for both.
You may ask yourself, "Why not just put all of the inspector code in the subclass".. To which I have to say there may be 100's of subclasses and I don't want to keep copying code.
I'd also note that I've seem similar, but not the same questions on here before.
Answer by Ziplock9000 · Jun 26, 2019 at 02:40 PM
Of course I find the answer right after I ask the question.
Here's how I got it working and it's quite obvious really:
1) The subclasses custom editor class needs to derive from the base custom editor class not Unityeditor.Editor
2) In the sub class's OnInspectorGUI, you need to call the base classes UI render with base.OnInspectorGUI();
Your answer
Follow this Question
Related Questions
Unity IDE pure keyboard navigation possible?, 0 Answers
I am having a problem with my cursor when I hover over a Game object? 0 Answers
Scroll Rect. Unnable to place my layout at left side. 0 Answers
How can I change the unity editor completely? 0 Answers
Calling functions via buttons when cooldown finished 1 Answer