Commit a0fd194e cgx

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

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