Quantcast
Channel: Questions in topic: "xcode"
Viewing all articles
Browse latest Browse all 1047

Override UnityAppController in iOS

$
0
0
I want to pass a parameter to an Unity iOS app via a URL using an iOS plugin. I have successfully passed a parameter via URL by adding/editing the following the UnityAppController in Xcode: - (void) callUnitySendMessage:(const char*)object Method:(const char*)method Parameter:(const char*)parameter { UnitySendMessage(object, method, parameter); } - (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation { NSString* hostString = url.host; [self callUnitySendMessage:"NativeInterfaceReceiver" Method:"TestThisFunction" Parameter:hostString.UTF8String]; NSMutableArray* keys = [NSMutableArray arrayWithCapacity:3]; NSMutableArray* values = [NSMutableArray arrayWithCapacity:3]; #define ADD_ITEM(item) do{ if(item) {[keys addObject:@#item]; [values addObject:item];} }while(0) ADD_ITEM(url); ADD_ITEM(sourceApplication); ADD_ITEM(annotation); #undef ADD_ITEM NSDictionary* notifData = [NSDictionary dictionaryWithObjects:values forKeys:keys]; AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData); return YES; } I’d prefer to do this via a Unity plugin so that I don’t have to edit anything in Xcode. I figure I should be able to do this by overriding this function with a subclass of UnityAppController called MyAppController under Plugins/iOS. But how do I get MyAppController to replace UnityAppController? This is what I have so far--not sure if I'm on the right track. ![alt text][1] ![alt text][2] [1]: /storage/temp/71881-myapph.png [2]: /storage/temp/71882-myappmm.png

Viewing all articles
Browse latest Browse all 1047

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>