diff --git a/Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.cs b/Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.cs index 7cb6a64..c29d318 100644 --- a/Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.cs +++ b/Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.cs @@ -2,11 +2,14 @@ using System.Collections.Generic; using UnityEngine; + +/// +/// Example of a script using [HideInPrfab] +/// public class HideInPrefabExample : MonoBehaviour { [Header ("Drag Me into scene to show hidden properties.")] - [HideInPrefab] public float HiddenFloat = 5; //Hidden in prefab inspector public float ShownFloat = 6; //Not hidden in prefab inspector diff --git a/Assets/Editor Add On/Custom Attributes/Hide in Prefab/Scripts/HideInPrefabAttribute.cs b/Assets/Editor Add On/Custom Attributes/Hide in Prefab/Scripts/HideInPrefabAttribute.cs index 17ee791..02b924a 100644 --- a/Assets/Editor Add On/Custom Attributes/Hide in Prefab/Scripts/HideInPrefabAttribute.cs +++ b/Assets/Editor Add On/Custom Attributes/Hide in Prefab/Scripts/HideInPrefabAttribute.cs @@ -4,29 +4,50 @@ 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 diff --git a/Assets/Editor.meta b/Assets/Editor.meta deleted file mode 100644 index 178ee3f..0000000 --- a/Assets/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d2ef7c61cf0a63a439bf63d461541ce3 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: