22
33### TODO
44- [x] Assets References
5- - [ ] AOT support
5+ - [x ] AOT support
66- [ ] Component that automaticaly will save/load components with implemented interface
77- [ ] Scene References
88
@@ -86,24 +86,6 @@ using UnityEngine;
8686
8787public class Player : MonoBehaviour
8888{
89- private struct SaveData
90- {
91- [SerializeField ] private float _health ;
92- [SerializeField ] private Vector3 _position ;
93- [SerializeField ] private List <Item > _inventory ;
94-
95- public float Health => _health ;
96- public Vector3 Position => _position ;
97- public List <Item > Inventory => _inventory ;
98-
99- public SaveData (float health , Vector3 position , List <Item > inventory )
100- {
101- _health = health ;
102- _position = position ;
103- _inventory = inventory ;
104- }
105- }
106-
10789 [SerializeField ] private float _health = 0 f ;
10890 [SerializeField ] private List <Item > _inventory = new List <Item >();
10991
@@ -136,6 +118,24 @@ public class Item : ScriptableObject
136118 [SerializeField ] private string _name = string .Empty ;
137119 [SerializeField ] private int _cost = 100 ;
138120}
121+
122+ public struct SaveData
123+ {
124+ [SerializeField ] private float _health ;
125+ [SerializeField ] private Vector3 _position ;
126+ [SerializeField ] private List <Item > _inventory ;
127+
128+ public float Health => _health ;
129+ public Vector3 Position => _position ;
130+ public List <Item > Inventory => _inventory ;
131+
132+ public SaveData (float health , Vector3 position , List <Item > inventory )
133+ {
134+ _health = health ;
135+ _position = position ;
136+ _inventory = inventory ;
137+ }
138+ }
139139```
140140
141141### How to make asset saveable
@@ -152,6 +152,32 @@ public class Item : ScriptableObject
152152
153153![ image] ( https://user-images.githubusercontent.com/53948684/117006947-776b6980-ad02-11eb-997c-e9108e5c3f97.png )
154154
155+ ### AOT platforms
156+
157+ You need to create simple C# class and implement ``` ITypeProvider ``` interface. Then you need to add types (except primitive) that will be saved in your game.
158+
159+ Example for case above
160+
161+ ``` csharp
162+ using System ;
163+ using System .Collections .Generic ;
164+ using ToolBox .Serialization ;
165+ using UnityEngine ;
166+
167+ public sealed class TestProvider : ITypeProvider
168+ {
169+ public Type [] GetTypes ()
170+ {
171+ return new Type []
172+ {
173+ typeof (SaveData ),
174+ typeof (Vector3 ),
175+ typeof (List <Item >)
176+ };
177+ }
178+ }
179+
180+ ```
155181
156182## Performance test
157183
0 commit comments