- Home /
Question by
Guy-Corbett · Sep 09, 2015 at 06:52 PM ·
inspectorlayoutcustom inspector
Add to an built in custom inspector
Hi all,
I have a class which inherits from the VerticalLayoutGroup and adds one use variable. It, omitting the stuff not relevant to this question, looks a bit like this;
public class AbsoluteVerticalLayoutGroup : VerticalLayoutGroup
{
[SerializeField]
private bool m_useScreenSize = false;
}
However the inspector being used in Unity's editor isn't picking up my new variable presumably because it's a custom editor Unity provides for the VerticalLayoutGroup. It looks like this still;
I want to be able to add my new variable to the inspector but can't see how. It feels like I should be able to just inherit from this existing inspector like this;
[CustomEditor(typeof(AbsoluteVerticalLayoutGroup))]
public class AbsoluteVerticalLayoutGroupEditor: VerticalLayoutGroupEditor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
AbsoluteVerticalLayoutGroupEditor myScript = (AbsoluteVerticalLayoutGroupEditor)target;
myScript.m_useScreenSize = GUILayout.Toggle(myScript.m_useScreenSize, "Use Screen Size");
}
}
But I don't know what the exiting inspector is called, VerticalLayoutGroupEditor is just my guess and that doesn't exist. Any suggestions on how I might achieve this, ideally without writing the inspector from scratch?
inspector.png
(7.6 kB)
Comment