I'm developing an editor plugin, and I would like to be able to hide the MonoBehaviours that my plugin attaches to a GameObject to decrease clutter for the user (since there could potentially be a very large number of MonoBehaviours that the user shouldn't be able to modify directly anyways).
Is there a method of doing this? I tried setting the hideFlags of the MonoBehaviours to HideFlags.HideInInspector, but that didn't seem to work.
Consider adding your custom components to a new child gameobject, and on Start(), have that gameobject transfer the components to its parent (or modify the scripts to work on their parent).
I think that you can then set the child object's .HideFlags to prevent the user from editing it -
Like Veehmot said, you can use HideFlags. I ran into a problem however, in Unity 4.1.1 at least. The component becomes visible again if you press Apply or look at the Inspector of a prefab.
The solution would be to create a custom Inspector for the component and then set the HideFlags in the OnEnable() function of that custom Inspector/Editor. This obviously don;t help for something like Transform but this should be an option for your own components/ monobehaviours.
In my case I had another component that is creating and using the ones I’m adding to the gameObject and it is keeping a reference to them, so I simply used its OnEnable() to do the HideFlag checks and did not need to write a custom inspector for each of the other components. This could be a way to do it for Transform and other such components too.
Something else I’ve noticed is that the HideFlag will stick if you created the prefab directly via the whole PrefabUtility.CreateEmptyPrefab/ReplacePrefab thing and then added the components to be hidden to it.