gkngkc / UnityStandaloneFileBrowser

A native file browser for unity standalone platforms
MIT License
2.01k stars 317 forks source link

Added Linux support (WIP) #41

Closed RicardoEPRodrigues closed 5 years ago

RicardoEPRodrigues commented 5 years ago

Copied Mac OS File Browser c# and added similar behavior.

Used C and GTK to create a Dialog to select files.

WHAT DOES NOT WORK: file saving and Async.

gkngkc commented 5 years ago

That's awesome. Thank you very much.

RicardoEPRodrigues commented 5 years ago

when I have the time I'll complete the rest, file saving at least. :smile:

gkngkc commented 5 years ago

I wrote simple file save functionality by modifying your file open code, here. Please do not hesitate to do corrections, And don't worry about the async, threading is hard and not worth the effort 😄

Thanks again for your amazing contribution.

Cheers!

RicardoEPRodrigues commented 5 years ago

It's very simple and nice!

It is weird, but the last loop is what makes this all work well:

while (gtk_events_pending ())
    gtk_main_iteration ();
gkngkc commented 5 years ago

Yeah, gtk environment is weird.

I tried to get root GtkWindow for parent parameter. but didn't figured it out. Probably unity creates GtkApplication and GtkWindow somewhere internally, but doesn't expose them for use.

Tried to do this but no luck. It returns NULL for GApplication

GtkApplication* app = GTK_APPLICATION (g_application_get_default (); GtkWindow* window = gtk_application_get_active_window (app);

Anyway, i have no idea how gtk works :)

RicardoEPRodrigues commented 5 years ago

Unity uses GTK on the Editor side. The Standalone doesn't use GTK internally, so we have to initialize it and deal with the loop.

gkngkc commented 5 years ago

Oh, i understand.