private void OnEnable()
 {
     _targetProp          = serializedObject.FindProperty(TargetPropName);
     _assetProp           = serializedObject.FindProperty(AssetPropName);
     _contextProp         = serializedObject.FindProperty(ContextPropName);
     _selfStyleListEditor = new StyleListEditor(serializedObject, Apply, true);
 }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            StyleEditorEx.DrawContextField(_contextProp);

            DrawPropertiesExcluding(serializedObject, ExcludedProperties);

            EditorGUILayout.ObjectField(_targetProp);

            if (_targetProp.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("Target is null", MessageType.Error);
            }

            GUILayout.Space(10);

            if (_assetProp != null)
            {
                EditorGUILayout.ObjectField(_assetProp);
            }

            if (_assetProp?.objectReferenceValue != null)
            {
                if (_styleAssetSerializedObject?.targetObject != _assetProp.objectReferenceValue)
                {
                    _styleAssetSerializedObject?.Dispose();

                    _styleAssetSerializedObject = new SerializedObject(_assetProp.objectReferenceValue);
                    _assetStyleListEditor       = new StyleListEditor(_styleAssetSerializedObject, Apply, false);
                }

                _assetStyleListEditor.DoLayout();
            }
            else
            {
                _styleAssetSerializedObject?.Dispose();
                _styleAssetSerializedObject = null;

                _selfStyleListEditor.DoLayout();
            }

            serializedObject.ApplyModifiedProperties();
        }
 private void OnEnable()
 {
     _styleListEditor = new StyleListEditor(serializedObject, Apply, true);
 }