Skip to content

Commit d019211

Browse files
authored
Serialize base (#25)
* any nullable class * fix drawer * any nullable struct * code-gen by property of field in class or struct * hack: generate fields of class by any serialize for AnySerializable classes only. * fix sample of cycle classes * update version
1 parent 6abd24e commit d019211

28 files changed

+427
-663
lines changed

Assets/Samples/CycleClasses.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using UnityEngine;
3+
4+
namespace AnySerialize
5+
{
6+
public class CycleClasses : MonoBehaviour
7+
{
8+
[Serializable, AnySerializable]
9+
public class SelfCycle
10+
{
11+
public int Int;
12+
public SelfCycle Self;
13+
}
14+
15+
[AnySerialize(typeof(AnyValue<SelfCycle>))] public SelfCycle Self { get; }
16+
17+
[AnySerializable]
18+
public class SelfCycle2
19+
{
20+
public int Int;
21+
[AnySerialize(typeof(AnyNullableClass<SelfCycle2>))] public SelfCycle2 Self2 { get; }
22+
}
23+
24+
[AnySerialize] public SelfCycle2 Self2 { get; }
25+
}
26+
}

Assets/Samples/CycleClasses.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.

Assets/Samples/GameObject.prefab

Lines changed: 146 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ GameObject:
1010
m_Component:
1111
- component: {fileID: 7557180844171351635}
1212
- component: {fileID: 7557180844171351634}
13+
- component: {fileID: 2050478359041717691}
1314
m_Layer: 0
1415
m_Name: GameObject
1516
m_TagString: Untagged
@@ -27,6 +28,7 @@ Transform:
2728
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
2829
m_LocalPosition: {x: 0, y: 0, z: 0}
2930
m_LocalScale: {x: 1, y: 1, z: 1}
31+
m_ConstrainProportionsScale: 0
3032
m_Children: []
3133
m_Father: {fileID: 0}
3234
m_RootOrder: 0
@@ -43,4 +45,147 @@ MonoBehaviour:
4345
m_Script: {fileID: 11500000, guid: b255ee690891d1c46b8f93dcd95e33c3, type: 3}
4446
m_Name:
4547
m_EditorClassIdentifier:
46-
'[A] IntValue': 40
48+
<IntValue>k__BackingField:
49+
_value: 123
50+
<IntValueRO>k__BackingField:
51+
_value: 321
52+
<DictionaryStringInt>k__BackingField:
53+
_pairs:
54+
- _field0:
55+
_value: fdafda
56+
_field1:
57+
_value: 213
58+
- _field0:
59+
_value: fg1213
60+
_field1:
61+
_value: 34312
62+
<DictionaryStringDict>k__BackingField:
63+
_pairs:
64+
- _field0:
65+
_value: 3213
66+
_field1:
67+
_pairs:
68+
- _field0:
69+
_value: gfda
70+
_field1:
71+
_value: fdafda
72+
<AnyStringArray2>k__BackingField:
73+
_value:
74+
- _value:
75+
- jkfjkl123
76+
- fjio321
77+
- _value:
78+
- frewr
79+
<AnyIntArray3>k__BackingField:
80+
_value:
81+
- _value:
82+
- _value: 03000000bc010000
83+
- _value:
84+
- _value: 7b00000041010000
85+
- _value: 030000000200000001000000
86+
<AnyClassArray>k__BackingField:
87+
_value:
88+
- _field0:
89+
_value: 321
90+
_field1:
91+
_value: 123
92+
<A>k__BackingField:
93+
_field0:
94+
_value: 12333
95+
_field1:
96+
_value: 3333
97+
<B>k__BackingField:
98+
_field0:
99+
_value: 1
100+
_field1:
101+
_value: 0200000003000000
102+
_field2:
103+
_value:
104+
- _value: 0400000005000000
105+
_field3:
106+
_value: 123.321
107+
<BB>k__BackingField:
108+
_field0:
109+
_value: 0600000007000000
110+
_field1:
111+
_value:
112+
- _value: 04000000
113+
- _value: 05000000
114+
_field2:
115+
_value:
116+
- _value:
117+
- _value: 01000000
118+
- _value: 0200000003000000
119+
_field3:
120+
_value: 432321
121+
<Vector2>k__BackingField:
122+
_value: {x: 123, y: 123123}
123+
<Record>k__BackingField:
124+
_field0:
125+
_value: 5423321
126+
<LazyInt>k__BackingField:
127+
_value:
128+
_value: 321312
129+
<LazyIntArray>k__BackingField:
130+
_value:
131+
_value: e1100000c9140000
132+
<LazyDictIntLongArray>k__BackingField:
133+
_value:
134+
_pairs:
135+
- _field0:
136+
_value: 22222
137+
_field1:
138+
_value: e110000000000000211b420000000000
139+
- _field0:
140+
_value: 111
141+
_field1:
142+
_value: f3e0010000000000
143+
<IntValueROWithoutBacking>k__BackingField:
144+
_value: 333
145+
--- !u!114 &2050478359041717691
146+
MonoBehaviour:
147+
m_ObjectHideFlags: 0
148+
m_CorrespondingSourceObject: {fileID: 0}
149+
m_PrefabInstance: {fileID: 0}
150+
m_PrefabAsset: {fileID: 0}
151+
m_GameObject: {fileID: 7557180844171351637}
152+
m_Enabled: 1
153+
m_EditorHideFlags: 0
154+
m_Script: {fileID: 11500000, guid: 9752afb77b5043a7b59b931ca0525b5f, type: 3}
155+
m_Name:
156+
m_EditorClassIdentifier:
157+
<Self>k__BackingField:
158+
_value:
159+
Int: 1064
160+
<Self2>k__BackingField:
161+
_field0:
162+
_value: 2230
163+
_field1:
164+
<Value>k__BackingField:
165+
rid: 1828758672445276160
166+
references:
167+
version: 2
168+
RefIds:
169+
- rid: -2
170+
type: {class: , ns: , asm: }
171+
- rid: 1828758672445276160
172+
type: {class: CycleClasses/SelfCycle2, ns: AnySerialize, asm: AnySerialize.Samples}
173+
data:
174+
Int: 123
175+
<Self2>k__BackingField:
176+
<Value>k__BackingField:
177+
rid: 1828758672445276161
178+
- rid: 1828758672445276161
179+
type: {class: CycleClasses/SelfCycle2, ns: AnySerialize, asm: AnySerialize.Samples}
180+
data:
181+
Int: 44
182+
<Self2>k__BackingField:
183+
<Value>k__BackingField:
184+
rid: 1828758672445276162
185+
- rid: 1828758672445276162
186+
type: {class: CycleClasses/SelfCycle2, ns: AnySerialize, asm: AnySerialize.Samples}
187+
data:
188+
Int: 2222
189+
<Self2>k__BackingField:
190+
<Value>k__BackingField:
191+
rid: -2

0 commit comments

Comments
 (0)