File tree Expand file tree Collapse file tree
src/LitMotion/Assets/LitMotion.Animation/Editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33using UnityEditor . UIElements ;
44using System . Collections . Generic ;
55using UnityEngine ;
6- using UnityEditor . SceneManagement ;
76
87namespace LitMotion . Animation . Editor
98{
@@ -146,6 +145,24 @@ VisualElement CreateComponentsPanel()
146145 {
147146 if ( componentsProperty . arraySize != prevArraySize )
148147 {
148+ if ( prevArraySize < componentsProperty . arraySize )
149+ {
150+ var seen = new HashSet < object > ( ) ;
151+ bool dirty = false ;
152+ for ( int i = 0 ; i < componentsProperty . arraySize ; ++ i )
153+ {
154+ var element = componentsProperty . GetArrayElementAtIndex ( i ) ;
155+ var value = element . managedReferenceValue ;
156+ if ( value != null && ! seen . Add ( value ) )
157+ {
158+ var cloned = JsonUtility . FromJson ( JsonUtility . ToJson ( value ) , value . GetType ( ) ) ;
159+ element . managedReferenceValue = cloned ;
160+ dirty = true ;
161+ }
162+ }
163+ if ( dirty )
164+ serializedObject . ApplyModifiedProperties ( ) ;
165+ }
149166 RefleshComponentsView ( true ) ;
150167 prevArraySize = componentsProperty . arraySize ;
151168 }
You can’t perform that action at this time.
0 commit comments