Last active
August 3, 2023 09:15
-
-
Save sebtoun/d7df89e9cbb56878ac3fcca59b78e560 to your computer and use it in GitHub Desktop.
Layer Attribute for Unity Inspector (from https://answers.unity.com/questions/609385/type-for-layer-selection.html)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
/// <summary> | |
/// Attribute to select a single layer. | |
/// </summary> | |
public class LayerAttribute : PropertyAttribute | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
[ CustomPropertyDrawer( typeof( LayerAttribute ) ) ] | |
public class LayerAttributeDrawer : PropertyDrawer | |
{ | |
public override void OnGUI( Rect position, SerializedProperty property, GUIContent label ) | |
{ | |
property.intValue = EditorGUI.LayerField( position, label, property.intValue ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment