How can I use a GUIStyle in a Custom Editor which is set within that Custom Editor?

Hey folks. Experimenting with custom editors at the moment, and it would be handy to have a few GUIStyle s exposed at the start of the editor, which I can reference throughout. That way I can customise the visuals of my editor visually and interactively as I lay it out.

My MonoBehavior script has,

[SerializeField]
    public GUIStyle butStyle01 = new GUIStyle();

and in my Editor script, I’m trying to reference it as,

SerializedProperty butStyle01;

    private void OnEnable()
    {
        butStyle01 = serializedObject.FindProperty("butStyle01");
    }

    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        base.OnInspectorGUI();

        GUIStyle gah = butStyle01.objectReferenceValue as GUIStyle;

        GUILayout.Button("Woop!", gah);

I have no trouble getting the GUIStyle showing up in the Editor either as base.OnInspectorGUI or as a serialised property. However, I’m running into issues with the last lines - I can’t get access to the actual GUIStyle from the SerialisedProperty and/or I can’t seem to cast it as GUIStyle for use by the button on the last line.

Any clues, folks?

So, a solution to my own problem: Create a scriptable object, put your GUIStyles in there, reference the SO type in the MonoBehavior, get it as SerializedProperty in Editor script, internally cast it back to your SO type (eg. StylesForEditor moog = stylesForEditor.objectReferenceValue as StylesForEditor;) and access the GUIStyles from there. Bob’s yer uncle.