Guest User

Untitled

a guest
May 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor;
  4.  
  5.  
  6.  
  7. // This defines how the TagList should be drawn
  8. // in the inspector, when inspecting a GameObject with
  9. // a MonoBehaviour which uses the TagList attribute
  10.  
  11. [CustomPropertyDrawer(typeof(UnityLayerAttribute))]
  12. public class UnityLayerDrawer : PropertyDrawer
  13. {
  14. UnityLayerAttribute UnityLayer
  15. {
  16. get { return ((UnityLayerAttribute)attribute); }
  17. }
  18.  
  19. public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  20. {
  21. if (property.isExpanded)
  22. {
  23. return 2 * EditorGUIUtility.singleLineHeight;
  24. }
  25. else
  26. {
  27. return EditorGUIUtility.singleLineHeight;
  28. }
  29. }
  30.  
  31. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  32. {
  33. // Using BeginProperty / EndProperty on the parent property means that
  34. // prefab override logic works on the entire property.
  35. EditorGUI.BeginProperty(position, label, property);
  36.  
  37. //position = EditorGUI.PrefixLabel(position, label);
  38.  
  39. property.intValue = EditorGUI.LayerField(position, label, property.intValue);
  40. //EditorGUI.PropertyField(position, property);
  41.  
  42.  
  43. // Using BeginProperty / EndProperty on the parent property means that
  44. // prefab override logic works on the entire property.
  45. EditorGUI.EndProperty();
  46. }
  47. }
Add Comment
Please, Sign In to add comment