关于Inspector自定义的问题
unity3d吧
全部回复
仅看楼主
level 2
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label,true);
GUI.enabled = true;
}
我想自定义Inspector面板,让字段只读,但是用了上面的代码后普通字段可以,但是数组就不行,还能增删元素,查了很多api都没找到解决方案,求求大佬[泪]
2024年08月01日 09点08分 1
level 2
数组有默认样式,这个样式不包含在字段。如果你要禁用需要自定义Inspector
EditorGUILayout.LabelField("Custom Array Drawer", EditorStyles.boldLabel);
for (int i = 0; i < myArray.arraySize; i++)
{
SerializedProperty element = myArray.GetArrayElementAtIndex(i);
EditorGUILayout.PropertyField(element, new GUIContent($"Element {i}"), true);
}
2024年08月04日 05点08分 2
OK知道了,谢谢[太开心]
2024年08月06日 05点08分
1