diff --git a/src/LitMotion/Assets/LitMotion.Animation/Editor/LitMotionAnimationEditor.cs b/src/LitMotion/Assets/LitMotion.Animation/Editor/LitMotionAnimationEditor.cs index e9bcd1cd..fee85bfa 100644 --- a/src/LitMotion/Assets/LitMotion.Animation/Editor/LitMotionAnimationEditor.cs +++ b/src/LitMotion/Assets/LitMotion.Animation/Editor/LitMotionAnimationEditor.cs @@ -145,6 +145,24 @@ VisualElement CreateComponentsPanel() { if (componentsProperty.arraySize != prevArraySize) { + if (prevArraySize < componentsProperty.arraySize) + { + var seen = new HashSet(); + bool dirty = false; + for (int i = 0; i < componentsProperty.arraySize; ++i) + { + var element = componentsProperty.GetArrayElementAtIndex(i); + var value = element.managedReferenceValue; + if (value != null && !seen.Add(value)) + { + var cloned = JsonUtility.FromJson(JsonUtility.ToJson(value), value.GetType()); + element.managedReferenceValue = cloned; + dirty = true; + } + } + if (dirty) + serializedObject.ApplyModifiedProperties(); + } RefleshComponentsView(true); prevArraySize = componentsProperty.arraySize; }