[英]Unity Inspector draw arrays with different names
可以在 Inspector 中使用其属性(“名称”)中的自定义名称绘制序列化数组吗? (仍然会有扩展三角形)
所以而不是
-> 元素 0
-> 元素 1
这将是
-> 人
-> 汽车
有这样的课程:
[Serializable]
public class Group {
public string name;
public Vector3 someVec;
}
public List <Group> m_Groups; // Drawing groups in the inspector
PS 我正在使用 GetArrayElementAtIndex 遍历每个元素并单独绘制
找到了:
对于 GetArrayElementAtIndex 中的每个项目,使用:
EditorGUILayout.PropertyField(item, new GUIContent() { text = "New Title" });
其中“新标题”可以是当前 SerializedProperty 的属性,可以通过 property.stringValue 获得
例子:
for (int i = 0; i < list.arraySize; i++)
{
SerializedProperty group = list.GetArrayElementAtIndex(i);
SerializedProperty name = group.FindPropertyRelative("name");
EditorGUILayout.PropertyField(group, new GUIContent() { text = name.stringValue });
// Draw the subproperties...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.