Skip to content

Bug when recycled EnumPickerCell is reused for another Enum type #29

@nayuta-cr

Description

@nayuta-cr

リサイクルされた 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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions