27 lines
978 B
C#
27 lines
978 B
C#
using BracerLib.Data;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.TestTools;
|
|
|
|
namespace BracerLib.Editor.Data
|
|
{
|
|
/// <summary>
|
|
/// Referenced via: https://discussions.unity.com/t/select-only-one-layer-in-the-inspector-select-only-one-layer-in-the-inspector/230727
|
|
/// </summary>
|
|
[CustomPropertyDrawer(typeof(Layer))]
|
|
[ExcludeFromCoverage]
|
|
public class LayerPropertyDrawer : PropertyDrawer
|
|
{
|
|
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
|
{
|
|
EditorGUI.BeginProperty(position, GUIContent.none, property);
|
|
var layerIndex = property.FindPropertyRelative("layerIndex");
|
|
|
|
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
|
if (layerIndex != null)
|
|
layerIndex.intValue = EditorGUI.LayerField(position, layerIndex.intValue);
|
|
EditorGUI.EndProperty();
|
|
}
|
|
}
|
|
}
|