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
- Crash on when D3D12RenderPass::SetupDeviceResources when opening FBX animation preview
- Serialization errors are thrown when "com.unity.render-pipelines.core" is added as a custom package and Graphics window is opened
- Character Joints unexpectedly rotate when a ragdoll is created using the Ragdoll Wizard
- Crash on GfxDeviceD3D11Base::DrawBuffersBatchMode when rendering the Scene view
- The shared EditorBuildSettings.asset file of symlinked projects is not updated when changing the order of the Scenes in Build Settings in one of the projects
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;
}
}