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

Crash when embedding Unity into iOS

$
0
0
I'm trying to bring a Unity scene into our existing iOS application. I exported the Xcode project and modified the UnityAppController to keep it from taking over the app flow. Then on a button press I try to initialize the Unity stuff. Here's what I have: **ViewController** -(IBAction)clikedStart:(id)sender { _controller = [UnityController instance]; [_controller startUnity]; } **UnityController** +(UnityController*)instance { static UnityController* instance = nil; if(instance == nil) { UnityInitTrampoline(); RegisterMonoModules(); instance = [[UnityController alloc] init]; [instance setUpDisplay]; } return instance; } -(void)setUpDisplay { if ([UIDevice currentDevice].generatesDeviceOrientationNotifications == NO) [[UIDevice currentDevice]beginGeneratingDeviceOrientationNotifications]; [DisplayManager Initialize]; _mainDisplay = [[[DisplayManager Instance] mainDisplay] createView:YES showRightAway:NO]; _window = _mainDisplay->window; [KeyboardDelegate Initialize]; [self createViewHierarchy]; UnityInitApplicationNoGraphics([[[NSBundle mainBundle] bundlePath]UTF8String]); } -(void)startUnity { printf_console("-> Start Unity\n"); UnityInitApplicationGraphics(); // we make sure that first level gets correct display list and orientation [[DisplayManager Instance] updateDisplayListInUnity]; [self updateOrientationFromController:[SplashScreenController Instance]]; UnityLoadApplication(); Profiler_InitProfiler(); [self showGameUI]; [self createDisplayLink]; } -(void)resumeUnity { printf_console("-> Resume Unity\n"); if(_unityAppReady) { if(_didResignActive) UnityPause(false); } else { [self performSelector:@selector(startUnity) withObject:nil afterDelay:0]; } [GetController().unityView recreateGLESSurfaceIfNeeded]; _didResignActive = false; } -(void)pauseUnity { printf_console("-> Pause Unity\n"); if(_unityAppReady) { UnityPause(true); extern void UnityStopVideoIfPlaying(); UnityStopVideoIfPlaying(); // Force player to do one more frame, so scripts get a chance to render custom screen for // minimized app in task manager. UnityForcedPlayerLoop(); [self repaintDisplayLink]; } _didResignActive = true; } -(void)stopUnity { printf_console("-> Stop Unity\n"); Profiler_UninitProfiler(); UnityCleanup(); } -(void)dealloc { extern void SensorsCleanup(); SensorsCleanup(); [self releaseViewHierarchy]; [super dealloc]; } But it's crashing down in `UnityInitApplicationNoGraphics([[[NSBundle mainBundle] bundlePath]UTF8String]);` with this stack #0 0x00b9488c in std::_Rb_tree, std::_Select1st>, std::less, stl_allocator, (MemLabelIdentifier)1, 16>>::_M_begin() [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/c++/4.2.1/bits/stl_tree.h:476 #1 0x00b9488c in std::_Rb_tree, std::_Select1st>, std::less, stl_allocator, (MemLabelIdentifier)1, 16>>::find(int const&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/c++/4.2.1/bits/stl_tree.h:1373 #2 0x00b94874 in std::map, stl_allocator, (MemLabelIdentifier)1, 16>>::find(int const&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/c++/4.2.1/bits/stl_map.h:542 #3 0x00b94874 in Object::ClassIDToRTTI(int) at /Applications/buildAgent/work/d63dfc6385190b60/Runtime/BaseClasses/BaseObject.cpp:828 #4 0x00b9b88c in Unity::GameObject::RegisterClass() at /Applications/buildAgent/work/d63dfc6385190b60/Runtime/BaseClasses/GameObject.cpp:1374 #5 0x00b94f48 in Object::InitializeAllClasses() at /Applications/buildAgent/work/d63dfc6385190b60/Runtime/BaseClasses/BaseObject.cpp:903 #6 0x00cda400 in InitializeEngineNoGraphics() at /Applications/buildAgent/work/d63dfc6385190b60/Runtime/Misc/SaveAndLoadHelper.cpp:210 #7 0x00ccb594 in PlayerInitEngineNoGraphics(std::string const&, std::string const&) at /Applications/buildAgent/work/d63dfc6385190b60/Runtime/Misc/Player.cpp:711 #8 0x00ac6170 in UnityInitApplicationNoGraphics at /Applications/buildAgent/work/d63dfc6385190b60/PlatformDependent/iPhonePlayer/LibEntryPoint.mm:188 Specifically on this line of the assembly `0xbc288c: ldr r3, [r1]` Has anyone else managed to do this successfully? What am I missing?

Viewing all articles
Browse latest Browse all 1047

Trending Articles



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