UnityDebugSheet icon indicating copy to clipboard operation
UnityDebugSheet copied to clipboard

Bug when recycled EnumPickerCell is reused for another Enum type

Open nayuta-cr opened this issue 1 year ago • 0 comments

リサイクルされた EnumPickerCell が、別の Enum 型用に再利用されるときに、 Enum 選択肢が以前の型のものになってしまうバグを見つけました。

手元で以下のような変更を行ったところ、うまく動作するようになりました:

--- a/Assets/UnityDebugSheet/Runtime/Core/Scripts/DefaultImpl/Cells/EnumPickerCell.cs
+++ b/Assets/UnityDebugSheet/Runtime/Core/Scripts/DefaultImpl/Cells/EnumPickerCell.cs
@@ -29,6 +29,15 @@ public sealed class EnumPickerCell : Cell<EnumPickerCellModel>

         protected override void SetModel(EnumPickerCellModel model)
         {
+            if (_isInitialized && 0 < _values.Count)
+            {
+                if (_values[0].GetType() != model.ActiveValue.GetType())
+                {
+                    _options.Clear();
+                    _values.Clear();
+                    _isInitialized = false;
+                }
+            }
             if (!_isInitialized)
             {
                 var enumType = model.ActiveValue.GetType();

nayuta-cr avatar Jun 25 '24 07:06 nayuta-cr