Skip to content

Commit 17c1c4f

Browse files
committed
fix: adding the new tag to inherited collections
1 parent 57deaa6 commit 17c1c4f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Scripts/Editor/Core/CodeGenerationUtility.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,19 @@ private static void WriteDirectAccessCollectionStatic(ScriptableObjectCollection
562562

563563
AppendLine(writer, indentation);
564564

565+
Type itemType = collection.GetItemType();
566+
bool writeAsPartial = SOCSettings.Instance.GetWriteAsPartialClass(collection);
567+
bool hasBaseTypeCollection = false;
565568

566-
AppendLine(writer, indentation,
567-
$"public static {collection.GetType().FullName} {PublicValuesName}");
569+
if (itemType != null && itemType.BaseType != null)
570+
{
571+
List<ScriptableObjectCollection> baseCollections = CollectionsRegistry.Instance.GetCollectionsByItemType(itemType.BaseType);
572+
hasBaseTypeCollection = baseCollections != null && baseCollections.Count > 0;
573+
}
574+
575+
bool addNewModifier = writeAsPartial && hasBaseTypeCollection;
576+
577+
AppendLine(writer, indentation, $"public {(addNewModifier ? "new " : string.Empty)}static {collection.GetType().FullName} {PublicValuesName}");
568578

569579
AppendLine(writer, indentation, "{");
570580
indentation++;

0 commit comments

Comments
 (0)