Skip to content

Commit 1547f7f

Browse files
Bruno MikoskiBruno Mikoski
authored andcommitted
add: backingfield support
1 parent 3f8e9dd commit 1547f7f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Scripts/Editor/Generators/CollectionGenerators.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Linq;
55
using System.Reflection;
6+
using BrunoMikoski.ScriptableObjectCollections.Utils;
67
using UnityEditor;
78
using UnityEngine;
89
using Object = UnityEngine.Object;
@@ -266,7 +267,11 @@ private static void CopyFieldToSerializedProperty(
266267
// Get the property to copy the value to.
267268
SerializedProperty serializedProperty = serializedObject.FindProperty(field.Name);
268269
if (serializedProperty == null)
269-
return;
270+
{
271+
serializedProperty = serializedObject.FindProperty(field.Name.AsBackingField());
272+
if(serializedProperty == null)
273+
return;
274+
}
270275

271276
object value = field.GetValue(owner);
272277

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace BrunoMikoski.ScriptableObjectCollections.Utils
2+
{
3+
public static class StringExtensions
4+
{
5+
public static string AsBackingField(this string value)
6+
{
7+
return $"<{value}>k__BackingField";
8+
}
9+
}
10+
}

Scripts/Editor/Utils/StringExtensions.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)