-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathUnity.cs
33 lines (28 loc) · 995 Bytes
/
Unity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using MongoDB.Bson;
using Realms;
using Realms.Sync;
using System.IO;
using System.Threading.Tasks;
public class Cube
{
private async void ReadCopy()
{
// :snippet-start: read_a_realm_unity
// After copying the above created file to the project folder,
// we can access it in Application.dataPath
// If you are using a local realm
var config = RealmConfiguration.DefaultConfiguration;
// If the realm is synced realm
var app = App.Create("myRealmAppId");
var user = await app.LogInAsync(Credentials.Anonymous());
config = new PartitionSyncConfiguration("myPartition", user);
if (!File.Exists(config.DatabasePath))
{//:uncomment-start:
//FileUtil.CopyFileOrDirectory(Path.Combine(Application.dataPath,
// "bundled.realm"), config.DatabasePath);
//:uncomment-end:
}
var realm = Realm.GetInstance(config);
// :snippet-end:
}
}