Commit a0fd194e cgx

解决Unity在静音模式下无法播放bug

1 个父辈 28bd1061
......@@ -14,6 +14,7 @@
#pragma mark - Unity
@property (nonatomic, strong) NSDictionary * appLaunchOpts;
@property (nonatomic, strong) UnityFramework* ufw;
/// 显示unity
- (void)showUnityView;
@end
......
......@@ -64,7 +64,7 @@
[[IQKeyboardManager sharedManager] setEnable:YES];
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:YES];
[[IQKeyboardManager sharedManager] setShouldResignOnTouchOutside:YES];
return YES;
}
......@@ -162,13 +162,10 @@
UnityFramework* UnityFrameworkLoad(void) {
NSString* bundlePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/Frameworks/UnityFramework.framework"];
NSBundle* bundle = [NSBundle bundleWithPath:bundlePath];
if ([bundle isLoaded] == false) [bundle load];
if ([bundle isLoaded] == false) { [bundle load]; }
UnityFramework* ufw = [bundle.principalClass getInstance];
if (![ufw appController])
{
[ufw setExecuteHeader: &_mh_execute_header];
}
UnityFramework *ufw = [bundle.principalClass getInstance];
if (![ufw appController]) { [ufw setExecuteHeader:&_mh_execute_header]; }
return ufw;
}
......@@ -180,17 +177,16 @@ extern int gArgc;
extern char** gArgv;
- (void)initUnity {
if([self unityIsInitialized]) {
[DSProgressHUD showDetailInfo:@"Unload Unity first"];
// unity如果初始化了,首先需要卸载unity
if ([self unityIsInitialized]) {
[DSProgressHUD showDetailInfo:@"Unity already initialized,please unload unity first"];
return;
}
[self setUfw: UnityFrameworkLoad()];
[self setUfw:UnityFrameworkLoad()];
[[self ufw] setDataBundleId:"com.unity3d.framework"];
[[self ufw] registerFrameworkListener:self];
[[self ufw] runEmbeddedWithArgc:gArgc argv:gArgv appLaunchOpts:self.appLaunchOpts];
[[[self ufw] appController] rootView];
}
- (void)showUnityView {
......@@ -201,15 +197,16 @@ extern char** gArgv;
#pragma mark - UnityFrameworkListener
- (void)unityDidUnload:(NSNotification*)notification {
DSLog(@"unityDidUnloaded called");
DSLog(@"unityDidUnload");
[self.window makeKeyAndVisible];
[[self ufw] unregisterFrameworkListener:self];
[self setUfw: nil];
[self.window makeKeyAndVisible];
}
- (void)unityDidQuit:(NSNotification *)notification {
DSLog(@"========== %s ============", __func__);
}
- (void)applicationWillResignActive:(UIApplication *)application { [[[self ufw] appController] applicationWillResignActive: application]; }
- (void)applicationDidEnterBackground:(UIApplication *)application { [[[self ufw] appController] applicationDidEnterBackground: application]; }
- (void)applicationWillEnterForeground:(UIApplication *)application { [[[self ufw] appController] applicationWillEnterForeground: application]; }
- (void)applicationDidBecomeActive:(UIApplication *)application { [[[self ufw] appController] applicationDidBecomeActive: application]; }
- (void)applicationWillTerminate:(UIApplication *)application { [[[self ufw] appController] applicationWillTerminate: application]; }
@end
......@@ -36,6 +36,7 @@ __attribute__ ((visibility("default")))
id<RenderPluginDelegate> _renderDelegate;
}
@property (strong, nonatomic) UIViewController *vc;
// override it to add your render plugin delegate
- (void)shouldAttachRenderDelegate;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!