using UnityEngine; #if UNITY_EDITOR using UnityEditor; #endif /// /// Class for the Hide in Prefab Attribute /// /// /// Class is empty because we have no parameters needed for this attribute /// public class HideInPrefabAttribute : PropertyAttribute { } #if UNITY_EDITOR /// /// Override for the Property Drawer which draws the GUI /// [CustomPropertyDrawer(typeof(HideInPrefabAttribute))] public class HideInPrefabDrawer : PropertyDrawer { //On GUI override public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { //get the type of the object this property is attched to PrefabType type = PrefabUtility.GetPrefabType(property.serializedObject.targetObject); //if the type isn't a perfab then draw the property if (type != PrefabType.Prefab) EditorGUI.PropertyField(position, property, label); } //Override GetPropertyHeight public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { //get the type of the object this property is attched to PrefabType type = PrefabUtility.GetPrefabType(property.serializedObject.targetObject); //if type prefab return zero height (because it won't be drawn) if (type == PrefabType.Prefab) return 0; //else return normal height return base.GetPropertyHeight(property, label); } } #endif