From 15ff0215dccd4120d6cf68b3a6cb332f585eb686 Mon Sep 17 00:00:00 2001 From: Harlan Crystal Date: Fri, 24 Jan 2025 12:02:55 -0800 Subject: [PATCH] Disable the Unity LTS2020 property drawer recursive property crash worrkaround. It appears to work in LTS2022. (#56) * Disable the Unity LTS2020 property drawer recursive property crash workaround. It appears to work in LTS2022. --- CHANGELOG.md | 3 +++ Editor/Editor/ParameterReferenceDrawer.cs | 10 +++++++--- package.json | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44ba904..a619f6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All package updates & migration steps will be listed in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.3.2] - 2025-01-24 +- Disable the Unity LTS2020 property drawer recursive property crash workaround. It appears to work in LTS2022. + ## [4.3.1] - 2025-01-06 ### Fixed - `ReadOnlyListContainer` now throws `IndexOutOfRangeException` when accessed out of range. diff --git a/Editor/Editor/ParameterReferenceDrawer.cs b/Editor/Editor/ParameterReferenceDrawer.cs index 37255c9..55ccb33 100644 --- a/Editor/Editor/ParameterReferenceDrawer.cs +++ b/Editor/Editor/ParameterReferenceDrawer.cs @@ -55,8 +55,10 @@ public class ParameterReferenceDrawer : PropertyDrawer * with in inner list also called _rewards. The recursive calls to to EditorGUI.PropertyField and * EditorGUI.GetPropertyHeight cause issues. * - * This was identified in LTS2020 (TBD if it's still an issue in newer editor versions) + * This was identified in LTS2020. In LTS2022, it appears to work without crashing. If you find yourself + * crashing, re-enable this workaround by flipping this bool. */ + private const bool ShouldWorkAroundRecursivePropertyNameBug = false; private static readonly Stack s_arrayPropertyNames = new(); private static Object s_firstTargetObject; @@ -154,7 +156,8 @@ private float InnerInspectorHeight(ParamProperty paramProperty, SerializedProper children = false; // don't draw class file if (prop.name == "m_Script") continue; - if (prop.isArray && s_arrayPropertyNames.Contains(prop.propertyPath)) + if (ShouldWorkAroundRecursivePropertyNameBug && + prop.isArray && s_arrayPropertyNames.Contains(prop.propertyPath)) height += EditorGUIUtility.singleLineHeight; else height += EditorGUI.GetPropertyHeight(prop, new GUIContent(prop.displayName), true); @@ -291,7 +294,8 @@ private bool DrawGUI(Rect position, SerializedProperty property, ParamProperty p if (prop.name == "m_Script") continue; float height; var propLabel = new GUIContent(prop.displayName); - if (prop.isArray && s_arrayPropertyNames.Contains(prop.propertyPath)) + if (ShouldWorkAroundRecursivePropertyNameBug && + prop.isArray && s_arrayPropertyNames.Contains(prop.propertyPath)) { height = EditorGUIUtility.singleLineHeight; var style = new GUIStyle(GUI.skin.label); diff --git a/package.json b/package.json index 03f0080..9d5ae7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.pocketgems.scriptableobject.flatbuffer", - "version": "4.3.1", + "version": "4.3.2", "displayName": "Scriptable Object - FlatBuffer", "description": "Seamless syncing between Scriptable Objects and CSVs. Scriptable Object data built to Google FlatBuffers for optimal runtime loading & access.", "unity": "2021.3",