diff --git a/SpineViewer/Spine/SpineView/SpineAnimationProperty.cs b/SpineViewer/Spine/SpineView/SpineAnimationProperty.cs index e46506f..1436e26 100644 --- a/SpineViewer/Spine/SpineView/SpineAnimationProperty.cs +++ b/SpineViewer/Spine/SpineView/SpineAnimationProperty.cs @@ -85,9 +85,9 @@ namespace SpineViewer.Spine.SpineView var props = new PropertyDescriptorCollection(TypeDescriptor.GetProperties(this, attributes, true).Cast().ToArray()); foreach (var i in Spine.GetTrackIndices()) { - if (!pdCache.ContainsKey(i)) - pdCache[i] = new TrackWrapperPropertyDescriptor(i, [new DisplayNameAttribute($"轨道 {i}")]); - props.Add(pdCache[i]); + if (!pdCache.TryGetValue(i, out var pd)) + pdCache[i] = pd = new TrackWrapperPropertyDescriptor(i, [new DisplayNameAttribute($"轨道 {i}")]); + props.Add(pd); } return props; } diff --git a/SpineViewer/Spine/SpineView/SpineSkinProperty.cs b/SpineViewer/Spine/SpineView/SpineSkinProperty.cs index 0b4635d..7d30dfb 100644 --- a/SpineViewer/Spine/SpineView/SpineSkinProperty.cs +++ b/SpineViewer/Spine/SpineView/SpineSkinProperty.cs @@ -53,9 +53,9 @@ namespace SpineViewer.Spine.SpineView var props = new PropertyDescriptorCollection(TypeDescriptor.GetProperties(this, attributes, true).Cast().ToArray()); foreach (var name in Spine.SkinNames) { - if (!pdCache.ContainsKey(name)) - pdCache[name] = new SkinPropertyDescriptor(name, [new DisplayNameAttribute(name)]); - props.Add(pdCache[name]); + if (!pdCache.TryGetValue(name, out var pd)) + pdCache[name] = pd = new SkinPropertyDescriptor(name, [new DisplayNameAttribute(name)]); + props.Add(pd); } return props; }