Skip to content

Commit

Permalink
FIX: Mac image preview only shows spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangokce-infosfer committed Oct 16, 2017
1 parent e7890e7 commit 636db99
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 32 deletions.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Package/StandaloneFileBrowser.unitypackage
Binary file not shown.
50 changes: 20 additions & 30 deletions Plugins/MacOS/StandaloneFileBrowser/Plugin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,16 @@ - (void)dialogOpenFilePanelAsync:(NSString*)title
multiselect:multiselect
canChooseFiles:canChooseFiles
canChooseFolders:canChooseFolders];
if (panel) {
dispatch_async(dispatch_get_main_queue(), ^{
if ([panel runModal] == NSModalResponseOK) {
if ([[panel URLs] count] > 0) {
NSString* seperator = [NSString stringWithFormat:@"%c", 28];
NSString* paths = [[panel URLs] componentsJoinedByString:seperator];
asyncCallback([paths UTF8String]);
return;
}
}
asyncCallback([@"" UTF8String]);
});
}
else {
asyncCallback([@"" UTF8String]);
[self performSelectorOnMainThread:@selector(dialogOpenFilePanelAsyncSelector:) withObject:panel waitUntilDone:NO];
}

- (void)dialogOpenFilePanelAsyncSelector:(NSOpenPanel*)panel {
NSString* paths = @"";
if (panel && [panel runModal] == NSModalResponseOK && [[panel URLs] count] > 0) {
NSString* seperator = [NSString stringWithFormat:@"%c", 28];
paths = [[panel URLs] componentsJoinedByString:seperator];
}
asyncCallback([paths UTF8String]);
}

- (NSOpenPanel*)createOpenPanel:(NSString*)title
Expand Down Expand Up @@ -229,23 +223,19 @@ - (void)dialogSaveFilePanelAsync:(NSString*)title
directory:directory
defaultName:defaultName
filters:filters];
if (panel) {
dispatch_async(dispatch_get_main_queue(), ^{
if ([panel runModal] == NSModalResponseOK) {
NSURL *URL = [panel URL];
if (URL) {
asyncCallback([[URL path] UTF8String]);
return;
}
}
asyncCallback([@"" UTF8String]);
});
}
else {
asyncCallback([@"" UTF8String]);
}
[self performSelectorOnMainThread:@selector(dialogSaveFilePanelAsyncSelector:) withObject:panel waitUntilDone:NO];
}

- (void)dialogSaveFilePanelAsyncSelector:(NSSavePanel*)panel {
NSString* path = @"";
if (panel && [panel runModal] == NSModalResponseOK) {
NSURL *URL = [panel URL];
if (URL) {
path = [URL path];
}
}
asyncCallback([path UTF8String]);
}

- (NSSavePanel*)createSavePanel:(NSString*)title
directory:(NSString*)directory
Expand Down
4 changes: 4 additions & 0 deletions Plugins/MacOS/StandaloneFileBrowser/Plugin.pch
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ extern "C" {
canChooseFiles:(BOOL)canChooseFiles
canChooseFolders:(BOOL)canChooseFolders;

- (void)dialogOpenFilePanelAsyncSelector:(NSOpenPanel*)panel;

- (void)dialogSaveFilePanelAsync:(NSString*)title
directory:(NSString*)directory
defaultName:(NSString*)defaultName
filters:(NSString*)filters;

- (void)dialogSaveFilePanelAsyncSelector:(NSOpenPanel*)panel;

- (NSOpenPanel*)createOpenPanel:(NSString*)title
directory:(NSString*)directory
filters:(NSString*)filters
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
m_EditorVersion: 2017.1.1f1
m_EditorVersion: 2017.1.0f3

0 comments on commit 636db99

Please sign in to comment.