SerializedObject SerializedPropoerty not editable grayed out.

It might be of help for people that got grayed out fields after using EditorGUILayout.PropertyField.

I wanted to have EditorWindow but use Component to have easier time with fields.
I wanted to use OnGui of EditorWindow like this:

private void OnGUI()
{
    foreach (var serializedProperty in _serializedProperties)
    {
        EditorGUILayout.PropertyField(serializedProperty);
    }
}

For this to happen I needed to obtain SerializedObject and SerializedProperties of fields.

I did it like this

//var go = new GameObject("") { hideFlags = HideFlags.HideAndDontSave, }; //this will not work
var go = new GameObject("");
var component = go.AddComponent<MyComponent>();
_component = component;
var serializedObject = new SerializedObject(component);

If you use HideFlags.HideAndDontSave on a GameObject the fields are going to be grayed out.
Turns out HideAndDontSave is also NotEditable :rage:.
You have to use
hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy,