File tree Expand file tree Collapse file tree
Assets/Editor Toolbox/Editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,17 +9,18 @@ namespace Toolbox.Editor.ContextMenu.Operations
99 /// </summary>
1010 internal class CopySerializeReferenceCache
1111 {
12- public CopySerializeReferenceCache ( Type referenceType , IReadOnlyList < CopySerializeReferenceEntry > entires )
12+ public CopySerializeReferenceCache ( Type referenceType , IReadOnlyList < CopySerializeReferenceEntry > entires , bool isArrayCopy )
1313 {
1414 ReferenceType = referenceType ;
1515 Entries = entires ;
16+ IsArrayCopy = isArrayCopy ;
1617 }
1718
1819 /// <summary>
1920 /// Base managed reference type of the source <see cref="UnityEditor.SerializedProperty"/>.
2021 /// </summary>
2122 public Type ReferenceType { get ; }
2223 public IReadOnlyList < CopySerializeReferenceEntry > Entries { get ; }
23- public bool IsArrayCopy => Entries != null && Entries . Count > 1 ;
24+ public bool IsArrayCopy { get ; }
2425 }
2526}
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ public bool IsEnabled(SerializedProperty property)
5151
5252 public void Perform ( SerializedProperty property )
5353 {
54+ var isArrayCopy = false ;
5455 var entries = new List < CopySerializeReferenceEntry > ( ) ;
5556 if ( property . propertyType == SerializedPropertyType . ManagedReference )
5657 {
@@ -59,6 +60,7 @@ public void Perform(SerializedProperty property)
5960 }
6061 else if ( property . isArray )
6162 {
63+ isArrayCopy = true ;
6264 var propertiesCount = property . arraySize ;
6365 for ( var i = 0 ; i < propertiesCount ; i ++ )
6466 {
@@ -69,7 +71,7 @@ public void Perform(SerializedProperty property)
6971 }
7072
7173 PropertyUtility . TryGetSerializeReferenceType ( property , out var referenceType ) ;
72- Cache = new CopySerializeReferenceCache ( referenceType , entries ) ;
74+ Cache = new CopySerializeReferenceCache ( referenceType , entries , isArrayCopy ) ;
7375 }
7476
7577 public GUIContent Label => new GUIContent ( "Copy Serialized References" ) ;
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ private bool IsAssignmentValid(Type targetType, CopySerializeReferenceEntry entr
3636 return true ;
3737 }
3838
39- return TypeUtility . IsTypeAssignableFrom ( targetType , entry . ReferenceType ) ;
39+ return TypeUtility . IsTypeAssignableFrom ( targetType , entryType ) ;
4040 }
4141
4242 private bool IsOperationSupported ( SerializedProperty targetProperty , CopySerializeReferenceCache cache )
Original file line number Diff line number Diff line change @@ -672,20 +672,21 @@ internal static bool IsSerializeReferenceProperty(SerializedProperty property)
672672
673673 internal static bool TryGetSerializeReferenceType ( SerializedProperty property , out Type referenceType )
674674 {
675- var fieldInfo = GetFieldInfo ( property , out var propertyType ) ;
675+ var fieldInfo = GetFieldInfo ( property , propertyType : out _ ) ;
676676 if ( fieldInfo == null )
677677 {
678678 referenceType = null ;
679679 return false ;
680680 }
681681
682- if ( property . isArray )
682+ var fieldType = fieldInfo . FieldType ;
683+ if ( property . isArray || IsSerializableArrayElement ( property ) )
683684 {
684- referenceType = GetElementTypeFromArrayType ( propertyType ) ;
685+ referenceType = GetElementTypeFromArrayType ( fieldType ) ;
685686 }
686687 else
687688 {
688- referenceType = fieldInfo . FieldType ;
689+ referenceType = fieldType ;
689690 }
690691
691692 return true ;
You can’t perform that action at this time.
0 commit comments