Browse Source

Merge branch 'feature/HideInPrefabAttribute' into develop

feature/Minesweeper
Joshua Reason 6 years ago
parent
commit
a2df77f3ab
11 changed files with 189 additions and 2 deletions
  1. +1
    -1
      Assets/Editor Add On.meta
  2. +1
    -1
      Assets/Editor Add On/Custom Attributes.meta
  3. +8
    -0
      Assets/Editor Add On/Custom Attributes/Hide in Prefab.meta
  4. +8
    -0
      Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples.meta
  5. +22
    -0
      Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.cs
  6. +11
    -0
      Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.cs.meta
  7. +58
    -0
      Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.prefab
  8. +8
    -0
      Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.prefab.meta
  9. +8
    -0
      Assets/Editor Add On/Custom Attributes/Hide in Prefab/Scripts.meta
  10. +53
    -0
      Assets/Editor Add On/Custom Attributes/Hide in Prefab/Scripts/HideInPrefabAttribute.cs
  11. +11
    -0
      Assets/Editor Add On/Custom Attributes/Hide in Prefab/Scripts/HideInPrefabAttribute.cs.meta

Assets/Editor.meta → Assets/Editor Add On.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d2ef7c61cf0a63a439bf63d461541ce3
guid: 7a8bfbd0555f21048abd1415f2c47893
folderAsset: yes
DefaultImporter:
externalObjects: {}

Assets/Editor/Editor AddOn.meta → Assets/Editor Add On/Custom Attributes.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 1eba5231ebd032b4db5d58d699e0f0de
guid: 040e0c0ec80bb52409744b03671df838
folderAsset: yes
DefaultImporter:
externalObjects: {}

+ 8
- 0
Assets/Editor Add On/Custom Attributes/Hide in Prefab.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f134e8ccabae44c45b14bad67978a30b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: affc4046c2a5111479cf285e82bedb4f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 22
- 0
Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.cs View File

@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Example of a script using [HideInPrfab]
/// </summary>
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
[HideInInspector]
public float AlwaysHiddenFloat = 7; //Always hidden (Unity's default implementation)
[HideInPrefab]
public GameObject HiddenGameObject; //Hidden in Prefab inspector
public GameObject ShownGameObject; //NotHidden in Prefab inspector
}

+ 11
- 0
Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b3a8b00c985891a448737258d9b09ede
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 58
- 0
Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.prefab View File

@ -0,0 +1,58 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1839211675386134}
m_IsPrefabParent: 1
--- !u!1 &1839211675386134
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4904693562653106}
- component: {fileID: 114800799608557334}
m_Layer: 0
m_Name: HideInPrefabExample
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4904693562653106
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1839211675386134}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114800799608557334
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1839211675386134}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b3a8b00c985891a448737258d9b09ede, type: 3}
m_Name:
m_EditorClassIdentifier:
HiddenFloat: 5
ShownFloat: 6
AlwaysHiddenFloat: 7
HiddenGameObject: {fileID: 0}
ShownGameObject: {fileID: 0}

+ 8
- 0
Assets/Editor Add On/Custom Attributes/Hide in Prefab/Examples/HideInPrefabExample.prefab.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3e4c28a2ff8a30f4da1d96c254a14fc5
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Editor Add On/Custom Attributes/Hide in Prefab/Scripts.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5629afcda35004c4d99c76bde4f4eeb7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 53
- 0
Assets/Editor Add On/Custom Attributes/Hide in Prefab/Scripts/HideInPrefabAttribute.cs View File

@ -0,0 +1,53 @@
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#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
{
}
#if UNITY_EDITOR
/// <summary>
/// Override for the Property Drawer which draws the GUI
/// </summary>
[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

+ 11
- 0
Assets/Editor Add On/Custom Attributes/Hide in Prefab/Scripts/HideInPrefabAttribute.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7ffee7f5af11da344ae52c6c92cce67c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Loading…
Cancel
Save