File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -114,9 +114,16 @@ IReadOnlyDictionary<TKey, TValue>
114114[AnySerializable]
115115public 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 ]
135143public 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+ ```
You can’t perform that action at this time.
0 commit comments