You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
857 B

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class HideInPrefabAttribute : PropertyAttribute
{
}
[CustomPropertyDrawer(typeof(HideInPrefabAttribute))]
public class HideInPrefabDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
PrefabType type = PrefabUtility.GetPrefabType(property.serializedObject.targetObject);
if (type != PrefabType.Prefab)
EditorGUI.PropertyField(position, property, label);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
PrefabType type = PrefabUtility.GetPrefabType(property.serializedObject.targetObject);
if (type == PrefabType.Prefab)
return 0;
return base.GetPropertyHeight(property, label);
}
}