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