我的变量隐藏在我的自定义检查器(PropertyDrawer)中
我要直接到这一点!我正在使用枚举器尝试选择要显示的变量,但是由于某种原因,变量不可见(一半可见)
<a href =“ https://i.sstatic.net/q9yl2.png” =“ nofollow noreferrer”>问题的示例
因此,这是代码的一部分,允许我显示和选择要显示的变量:
[CustomPropertyDrawer(typeof(QuestGoal))]
public class QuestGoal_PropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
SerializedProperty questType = property.FindPropertyRelative("questType");
SerializedProperty item = property.FindPropertyRelative("item");
SerializedProperty currentAmount = property.FindPropertyRelative("currentAmount");
SerializedProperty totalAmount = property.FindPropertyRelative("totalAmount");
SerializedProperty positionQuest = property.FindPropertyRelative("positionQuest");
float lineHeight = EditorGUIUtility.singleLineHeight;
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
EditorGUI.PropertyField(position, questType, GUIContent.none);
switch (questType.intValue)
{
case (int)QuestType.CRAFTING:
position = new Rect(position.x, position.y + lineHeight, position.width, position.height);
EditorGUI.PropertyField(position, item);
break;
case (int)QuestType.GATHERING:
position = new Rect(position.x, position.y + lineHeight, position.width, position.height);
EditorGUI.PropertyField(position, currentAmount);
position = new Rect(position.x, position.y + lineHeight * 2, position.width, position.height);
EditorGUI.PropertyField(position, totalAmount);
break;
case (int)QuestType.JOURNEY:
position = new Rect(position.x, position.y + lineHeight, position.width, position.height);
EditorGUI.PropertyField(position, positionQuest);
break;
default:
break;
}
EditorGUI.EndProperty();
}
}
Switch允许我选择我的变量,但是在枚举器之后有值的值仍然隐藏
I'm going straight to the point! I'm using an enumerator to try to choose the variables I want to display, but for some reason the variables are not visible (half visible)
So, here is the part of the code that allows me to display and choose which variable to display :
[CustomPropertyDrawer(typeof(QuestGoal))]
public class QuestGoal_PropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
SerializedProperty questType = property.FindPropertyRelative("questType");
SerializedProperty item = property.FindPropertyRelative("item");
SerializedProperty currentAmount = property.FindPropertyRelative("currentAmount");
SerializedProperty totalAmount = property.FindPropertyRelative("totalAmount");
SerializedProperty positionQuest = property.FindPropertyRelative("positionQuest");
float lineHeight = EditorGUIUtility.singleLineHeight;
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
EditorGUI.PropertyField(position, questType, GUIContent.none);
switch (questType.intValue)
{
case (int)QuestType.CRAFTING:
position = new Rect(position.x, position.y + lineHeight, position.width, position.height);
EditorGUI.PropertyField(position, item);
break;
case (int)QuestType.GATHERING:
position = new Rect(position.x, position.y + lineHeight, position.width, position.height);
EditorGUI.PropertyField(position, currentAmount);
position = new Rect(position.x, position.y + lineHeight * 2, position.width, position.height);
EditorGUI.PropertyField(position, totalAmount);
break;
case (int)QuestType.JOURNEY:
position = new Rect(position.x, position.y + lineHeight, position.width, position.height);
EditorGUI.PropertyField(position, positionQuest);
break;
default:
break;
}
EditorGUI.EndProperty();
}
}
The switch allows me to choose my variables but there values after the enumerator are still hidden
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
您需要实施:
因此编辑知道可以为您的财产保留多少空间。现在,您获得了默认高度(可能是EditorGuiutility.SingLelineHeight),您需要更多,因此您的属性已被删除
you need to implement:
so the editor knows how much space to reserve for your property. Now you got the default height (probably EditorGUIUtility.singleLineHeight) and you need more so your property is clipped