realm / realm-dotnet

Realm is a mobile database: a replacement for SQLite & ORMs
https://realm.io
Apache License 2.0
1.24k stars 161 forks source link

Unity Support #141

Closed kristiandupont closed 3 years ago

chrisk414 commented 4 years ago

@nirinchev

Yes, there is - we are in the process of migrating our assemblies to .NET standard. Then, Unity will need to add support for that (which they promised they'll do).

What they promised they'll do is fulfilled. What's the status on this? Is there a person who is actively looking into this? I'll have to figure out if I'll adopt Realm.

The current problem is that Realm.dll use P/Invoke calls to realm-wrapper.dll and it makes Unity to freeze when trying to unload realm-wrapper.dll.

A bright side is that it runs fine for the first run, and reading (not writing) from realm doesn't seem to call realm-wrapper.dll and it doesn't cause the freeze.

Until Realm supports Unity officially, I have to figure out a workaround. I think there are two workarounds.

  1. Is there a way to disable the automatic sync? I would like to find out if there is a way to manually sync. I'm aware that when I do the manual sync, I need to restart Unity.

  2. Just use a local realm file for Unity and create a separate daemon that syncs between the local realm file and the realm server. Is it possible to make such a daemon that can sync only changed objects?

I guess I prefer workaround #2, but I would like to know the answer to #1.

Please help make this possible. I'm sure there are tons of Unity users dying to use Realm.

Thanks.

nirinchev commented 4 years ago

We don't have anyone currently working on unity support, but is something that we're evaluating. You can keep an eye on the roadmap for updates.

chrisk414 commented 4 years ago

Well, I expected some answers to my question above but the answer is flat. hmm..

Anyway, let me ask you again.

Right now, I can only use Realm as a local db and I would like to know if there is a create a daemon that syncs between the local and online Realm.

In theory it's possible but I find that accessing local Realm while it's being used by other app creates freeze. I can't even edit using Realm Studio when an application uses it. I believe it doesn't mean to be designed like that. If it is, I'm very disappointed with the current limitation and it's almost unusable. You should fix this freeze at least so that I can do something with it until the full Unity support is in.

Oh well.. According to the roadmap, additional platform support will start toward the end of next year. That's pretty depressing to know, specially this topic has been opened for 4 years and nothing has been done on it.

Now that you have MongoDB backings, perhaps you should hire Unity specialists now instead of waiting for another year to get started.

I don't think you can say you are big on mobile without Unity support these days. My two cents.

nirinchev commented 4 years ago

If the issues with freezing you describe occur in a Unity project, then there's nothing we can do about it until we have official Unity support.

Regarding official Unity support, as I said, no one is working on it at the moment. We do have plans to expand the platforms we support, but we're not in a position to commit to a public timeframe. If you have a critical deadline by which you need to be able to run Realm in a Unity app, please reach out to your account executive or the sales team to describe your project requirements and deadlines. They may be able to give you a more specific roadmap.

chrisk414 commented 4 years ago

Ok, I get that you don't have a specific plan to support Unity now. And I'm really hoping that you would sooner than later.

I asked the question a couple of times already and let me ask you this question once again. I filed a support ticket but I was directed to ask on the forum. And it keeps going into the drain.

While an application is accessing local Realm, another application cannot write to the same realm. This includes Realm Studio. It is not related to Unity at all but I need to figure out the workaround.

What I'm trying to do is to create a daemon that syncs between a local Realm and online Realm while the local realm is being accessed by an application. This way, I can make Unity to read/write to local db while it gets synchronized to the online Realm.

I'm sure you didn't design Realm so that only one application can access it. If so, it has a serious design flaw as you cannot edit it from Realm Studio while some application is using it.

Please help answer the question above and I'll appreciate it. And let me know if the thread-safe version will fix it if it's the current limitation.

Thanks.

fealebenpae commented 4 years ago

Synchronized realm files can only be opened by one process at a time, that's why you can't open a synchronized realm with another application or with Realm Studio. That's only possible for realms opened using a RealmConfiguration, not FullSyncConfiguration or QueryBasedSyncConfiguration. If you can share a repro project or at least code samples of a RealmConfiguration realm not being able to be shared by two processes I'll try and help you out.

chrisk414 commented 4 years ago

Thanks, it's good to know that local Realm(ReamConfiguration) is "process" safe. I'll do some more testings and let you know what I find. Cheers!

Avatarchik commented 4 years ago

Hi!Did anyone get to use this database?

ianpward commented 3 years ago

Good news everyone! We have released Beta build support for Unity for our .NET SDK - take a look at an example blogpost here - https://developer.mongodb.com/how-to/getting-started-realm-sdk-unity/

We still have a bunch of things to do over the next quarter while we get our Unity SDK to GA but feel free to take it for a spin and let us know what you think! Additionally, if you are building a game and have local storage requirements we'd love to talk to you; our roadmap is still getting defined and we want to serve the gaming community with the best local database out there. If you are interested in speaking with us please drop me a line at ian.ward@mongodb.com for a quick chat

sandolkakos commented 3 years ago

Good news everyone! We have released Beta build support for Unity for our .NET SDK - take a look at an example blogpost here - https://developer.mongodb.com/how-to/getting-started-realm-sdk-unity/

We still have a bunch of things to do over the next quarter while we get our Unity SDK to GA but feel free to take it for a spin and let us know what you think! Additionally, if you are building a game and have local storage requirements we'd love to talk to you; our roadmap is still getting defined and we want to serve the gaming community with the best local database out there. If you are interested in speaking with us please drop me a line at ian.ward@mongodb.com for a quick chat

That is a very nice announcement. I was waiting for it for almost 5 years, and I'm gonna definitely give it a check over the next weekend.

nirinchev commented 3 years ago

For those willing to take it for a spin, be sure to get the package from the latest beta release as that addresses a whole lot of rough edges.

nirinchev commented 3 years ago

I'm incredibly excited to announce that the Unity SDK is now GA. We'll have a bunch of tutorials and sample apps in the pipeline, but for now, take a look at the docs for a quick getting started guide and browse through the examples at the end of the page if you're looking for inspiration or something more hands-on.

And as always, if you are facing difficulties or have suggestions how to improve the SDK, do let us know - we can't wait to see all the amazing games you'll build with Realm and Unity!

ianpward commented 3 years ago

To add on to what @nirinchev said - we'd love to hear about your game and what kind of requirements you have around data persistence. Realm is just getting started in the game development space and our roadmap is adapting to handle these requests. Drop us an email at ian.ward@mongodb.com and we can set up a time to talk about your game and answer any questions you might have - looking forward to speaking with you!

ianpward commented 2 years ago

Hey All - our Unity tutorial is live - https://docs.mongodb.com/realm/tutorial/unity/

We have both sync and non-sync versions of the walkthrough - let us know if you have any feedback and happy coding!