Created
April 30, 2016 14:22
-
-
Save dddnuts/86e7bd5bf23dc3507e10bc16e7cf6f05 to your computer and use it in GitHub Desktop.
An Unity iOS plugin to pick images from the album.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DDDImagePickerPlugin.mm | |
// Unity-iPhone | |
// | |
// Created by dddnuts on 4/29/16. | |
// | |
// | |
#import <Foundation/Foundation.h> | |
#import <QBImagePicker/QBImagePicker.h> | |
@interface DDDImagePickerDelegate : NSObject<QBImagePickerControllerDelegate> | |
+(instancetype)sharedInstance; | |
@end | |
@implementation DDDImagePickerDelegate | |
+(instancetype)sharedInstance | |
{ | |
static DDDImagePickerDelegate *instance; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
instance = [DDDImagePickerDelegate new]; | |
}); | |
return instance; | |
} | |
-(void)qb_imagePickerControllerDidCancel:(QBImagePickerController *)imagePickerController | |
{ | |
UIViewController *unityViewController = UnityGetGLViewController(); | |
[unityViewController dismissViewControllerAnimated:YES completion:nil]; | |
// TODO: Send message to Unity. | |
} | |
-(void)qb_imagePickerController:(QBImagePickerController *)imagePickerController didFinishPickingAssets:(NSArray *)assets | |
{ | |
UIViewController *unityViewController = UnityGetGLViewController(); | |
[unityViewController dismissViewControllerAnimated:YES completion:nil]; | |
// TODO: Send message with selected images to Unity. | |
} | |
@end | |
extern "C" { | |
void DDDImagePicker_Open() { | |
QBImagePickerController *picker = [QBImagePickerController new]; | |
picker.allowsMultipleSelection = YES; | |
picker.maximumNumberOfSelection = 2; | |
picker.showsNumberOfSelectedAssets = YES; | |
picker.delegate = [DDDImagePickerDelegate sharedInstance]; | |
UIViewController *unityViewController = UnityGetGLViewController(); | |
[unityViewController presentViewController:picker animated:YES completion:nil]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment