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
- Mesh Rendered GameObject using the SpriteLitDefault Material becomes invisible when animating with the URP Sprite-Lit-Default Shader
- Compilation errors occur when using PluginAPI headers in a C environment
- Profiler connects to a different opened Editor project when more than one project is open and building for WebGL with Autoconnect Profiler enabled
- Creating and then deleting the "Integration Update: Rotation" block breaks and makes unusable VFX Graph
- “ArgumentNullException: Value cannot be null.” when deleting a newly created input action
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;
}
}