Iterate through all component types


I would like to iterate through all component types to hide them in the inspector. It should look like this:

foreach (ComponentType in AllComponentTypes) {
	component.hideFlags = HideFlags.HideInInspector;
	EditorGUILayout.LabelField(component.GetType().Name + " is hidden");

How is it possible to do this?

thx advanced greetings =)

Well hide flags need to be implemented on each object - so it’s just

 foreach(var component in GetComponents<Component>())

One solution could be to have a public list, then inside of the editor you drag all components into it and then you itterate through that list?