Skip to content

Commit

Permalink
Added a method extension to copy a list of scriptable objects
Browse files Browse the repository at this point in the history
  • Loading branch information
omegaleo committed Nov 29, 2023
1 parent ceb612e commit 54e3c08
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Runtime/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using UnityEngine;

namespace OmegaLeo.Toolbox.Runtime.Extensions
{
public static class EnumerableExtensions
{
public static IEnumerable<T> Copy<T>(this IEnumerable<T> array) where T : ScriptableObject
{
foreach (var obj in array)
{
yield return obj.Copy();
}
}
}
}
3 changes: 3 additions & 0 deletions Runtime/Extensions/EnumerableExtensions.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Runtime/Extensions/IListExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Random = System.Random;

namespace OmegaLeo.Toolbox.Runtime.Extensions
{
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Extensions/ScriptableObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class ScriptableObjectExtensions
/// <summary>
/// Creates and returns a clone of any given scriptable object.
/// </summary>
public static T Clone<T>(this T scriptableObject) where T : ScriptableObject
public static T Copy<T>(this T scriptableObject) where T : ScriptableObject
{
if (scriptableObject == null)
{
Expand Down

0 comments on commit 54e3c08

Please sign in to comment.