add
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEditorHelper
|
||||
{
|
||||
[CustomPropertyDrawer(typeof (LimitAttribute))]
|
||||
public class LimitPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (property.propertyType != SerializedPropertyType.Integer)
|
||||
{
|
||||
Debug.LogWarning("LimitAttribute can only be applied on integer properties/fields");
|
||||
return;
|
||||
}
|
||||
|
||||
LimitAttribute limiter = attribute as LimitAttribute;
|
||||
property.intValue = limiter.Limit(EditorGUI.IntField(position, property.name, property.intValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user