Skip to content

Commit ab319db

Browse files
committed
Add SQLiteConnection.SerializeToAsset extension method
1 parent 7e3220b commit ab319db

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Runtime/SQLiteConnectionExtensions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using Unity.Collections;
2626
using Unity.Collections.LowLevel.Unsafe;
2727
#endif
28+
using UnityEngine;
2829

2930
namespace SQLite
3031
{
@@ -49,6 +50,16 @@ public static byte[] Serialize(this SQLiteConnection db, string schema = null)
4950
}
5051
}
5152

53+
public static SQLiteAsset SerializeToAsset(this SQLiteConnection db, string schema = null, SQLiteOpenFlags openFlags = SQLiteOpenFlags.ReadOnly, bool storeDateTimeAsTicks = true, string streamingAssetsPath = null)
54+
{
55+
SQLiteAsset asset = ScriptableObject.CreateInstance<SQLiteAsset>();
56+
asset.Bytes = db.Serialize(schema);
57+
asset.OpenFlags = openFlags;
58+
asset.StoreDateTimeAsTicks = storeDateTimeAsTicks;
59+
asset.StreamingAssetsPath = streamingAssetsPath;
60+
return asset;
61+
}
62+
5263
public static SQLiteConnection Deserialize(this SQLiteConnection db, byte[] buffer, string schema = null, SQLite3.DeserializeFlags flags = SQLite3.DeserializeFlags.None)
5364
{
5465
return Deserialize(db, buffer, buffer.LongLength, schema, flags);

0 commit comments

Comments
 (0)