Skip to content

Commit 5859894

Browse files
authored
Update README.md
1 parent ed07aac commit 5859894

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,16 @@ IReadOnlyDictionary<TKey, TValue>
114114
[AnySerializable]
115115
public class AnySerializableClass
116116
{
117+
[AnySerializeFieldOrder(0)] // optional, but recommend. prevent issue on reorder fields.
117118
public int[][] Array2;
119+
120+
[AnySerializeFieldOrder(1)]
118121
public Dictionary<int, string> Dict;
122+
123+
[AnySerializeFieldOrder(2)]
119124
public int? Nullable;
125+
126+
[AnySerializeFieldOrder(3)]
120127
public Lazy<int> Lazy;
121128
}
122129
```
@@ -131,6 +138,7 @@ public class AnySerializableClass
131138

132139
## Custom Serializable Types
133140
``` c#
141+
// custom serializable value type
134142
[Serializable]
135143
public class AnyGuid :
136144
IReadOnlyAny<Guid>, // IReadOnlyAny<T> for readonly property (get only)
@@ -145,3 +153,16 @@ public class AnyGuid :
145153
}
146154
}
147155
```
156+
``` c#
157+
// custom serializable container type
158+
[Serializable]
159+
// use AnyConstraintTypeAttribute on generic parameter to automatically find type by its constraint
160+
// e.g. T is int, then TAny will be replaced by AnyValue_Int32
161+
public class ReadOnlyAnyList<T, [AnyConstraintType] TAny>
162+
: IReadOnlyAny<List<T>>
163+
where TAny : IReadOnlyAny<T>
164+
{
165+
[SerializeField] private List<TAny> _value = default!;
166+
public List<T> Value => _value.Select(v => v.Value);
167+
}
168+
```

0 commit comments

Comments
 (0)