Ok. So with the help of @PAEvenson’s advice, I came up with a solution.
The key here is to have a custom editor. in that editor’s OnEnable() you can get the other components that you don’t want, and apply the hide flags.
This is your run time class.
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(BoxCollider))]
public class TestHide : MonoBehaviour {
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update () {
}
}
This is your editor class.
using UnityEngine;
using UnityEditor;
[CustomEditor (typeof(TestHide))]
public class TestHideEditor : Editor {
void OnEnable()
{
var castedTarget = (target as TestHide);
castedTarget.GetComponent<BoxCollider>().hideFlags = HideFlags.HideInInspector;
}
}