【发布时间】:2021-12-27 01:52:41
【问题描述】:
我有一个属性
public class LockAttribute : PropertyAttribute { }
使用自定义抽屉脚本
[CustomPropertyDrawer(typeof(LockAttribute))]
public class LockAttributePropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginDisabledGroup(Application.isPlaying);
_= EditorGUI.PropertyField(position, property, label);
EditorGUI.EndDisabledGroup();
}
}
它的目的是在应用程序播放时禁用检查器字段。
如果我按这个顺序使用它
[SerializeField,Range(0,100),Lock] private int m_Resolution;
该字段永远不会禁用,当我交换 Range 和 Lock 属性时,Range 属性无效。
有没有办法让两个属性都生效?
我尝试使用
Base.OnGUI(position, property, label);
而不是
EditorGUI.PropertyField(position, property, label);
但这样做会导致No GUI Implmented 出现在我的字段上`。
【问题讨论】:
标签: c# unity3d unity-editor unity3d-editor