Search Issue Tracker
By Design
Votes
0
Found in
2021.3.39f1
2022.3.31f1
6000.0.5f1
Issue ID
UUM-73083
Regression
No
Serializable fields become unselectable and cursor is not shown when an array is part of a struct in a List
Reproduction steps:
1. Open the attached “CustomDrawerRepro.zip” project
2. Click on the “RootScriptableObject.asset” in the Project Window
3. Expand the “Some Structs” property
4. Click on any of the input fields in the “Some Structs” property
Expected result: Cursor is shown and values are highlightable
Actual result: Fields are not selectable, cursor is not shown and values cannot be highlighted
Reproducible with: 2021.3.39f1, 2022.3.31f1, 6000.0.5f1
Reproducible on: Windows 11
Not reproducible on: no other environment tested
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Search field in UI Builder's Library has no character limit
- Changing the value in UI Builder by dragging increases it by a few thousand points when reaching the borders of the screen
- ARM64 architecture DLL incorrectly copied instead of x64 when building for Windows x64
- Crash on TypeTreeIterator::GetNode when opening a specific folder
- Crash on WriteSerializedAssetsV2 when (re)entering the Play Mode in a specific project when IEnumerator Start() is used
Resolution Note:
Thank you for your bug report regarding the issue with Serializable fields becoming unselectable. After further investigation, we have found that this problem originates from your custom property drawer.
Parts of IMGUI including the ReorderableList are stateful, which means they retain data about the SerializedObject and SerializedProperties. In your property drawer, you are generating a new SerializedObject every time and disposing of it right away. This process invalidates the state, which causes multiple drawings of the list, and also disrupts input states.
I made a small change to your property drawer to address this:
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(ChildScriptableObject), true)]
public class ChildScriptableObjectDrawer : PropertyDrawer
{
SerializedObject m_SerializedObject;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
position.height = EditorGUIUtility.singleLineHeight;
var objectFieldPosition = EditorGUI.PrefixLabel(position, label);
property.objectReferenceValue = EditorGUI.ObjectField(objectFieldPosition, property.objectReferenceValue, typeof(ChildScriptableObject), false);
position.y += position.height + EditorGUIUtility.standardVerticalSpacing;
if (property.objectReferenceValue != null)
{
m_SerializedObject ??= new SerializedObject(property.objectReferenceValue);
var prop = m_SerializedObject.GetIterator();
EditorGUI.indentLevel++;
bool children = true;
while (prop.NextVisible(children))
{
children = false;
// don't draw class file
if (prop.name == "m_Script") continue;
var propLabel = new GUIContent(prop.displayName);
float height = EditorGUI.GetPropertyHeight(prop, propLabel, true);
position.height = height;
EditorGUI.PropertyField(position, prop, propLabel, true);
position.y += height + EditorGUIUtility.standardVerticalSpacing;
}
EditorGUI.indentLevel--;
m_SerializedObject.ApplyModifiedProperties();
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float height = EditorGUIUtility.singleLineHeight;
if (property.objectReferenceValue == null)
return height;
m_SerializedObject ??= new SerializedObject(property.objectReferenceValue);
var prop = m_SerializedObject.GetIterator();
bool children = true;
while (prop.NextVisible(children))
{
children = false;
// don't draw class file
if (prop.name == "m_Script") continue;
height += EditorGUI.GetPropertyHeight(prop, new GUIContent(prop.displayName), true);
height += EditorGUIUtility.standardVerticalSpacing;
}
return height;
}
}