Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit fb3f3ce2
由
cgx
编写于
2022-06-01 10:47:10 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化unity
1 个父辈
5d1f390f
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
58 行增加
和
71 行删除
DreamSleep/DreamSleep/Basement/Utils/MacroFuncUtil.h
DreamSleep/DreamSleep/Class/HomeModule/FallAsleep/ThreeMinuteController.h
DreamSleep/DreamSleep/Class/HomeModule/FallAsleep/ThreeMinuteController.m
DreamSleep/DreamSleep/Class/Start/Root/AppDelegate.h
DreamSleep/DreamSleep/Class/Start/Root/AppDelegate.m
DreamSleep/TapiOS/Classes/UI/UnityAppController+ViewHandling.mm
DreamSleep/TapiOS/Classes/UnityAppController.mm
DreamSleep/DreamSleep/Basement/Utils/MacroFuncUtil.h
查看文件 @
fb3f3ce
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
// APP和KeyWindow
// APP和KeyWindow
#define DSApplication [UIApplication sharedApplication]
#define DSApplication [UIApplication sharedApplication]
#define DSKeyWindow DSApplication.keyWindow
#define DSKeyWindow DSApplication.keyWindow
#define DSDelegateWindow DSApplication.delegate.window
// 系统及APP版本
// 系统及APP版本
#define DSSystemVersion ([[[UIDevice currentDevice] systemVersion] floatValue])
#define DSSystemVersion ([[[UIDevice currentDevice] systemVersion] floatValue])
...
...
DreamSleep/DreamSleep/Class/HomeModule/FallAsleep/ThreeMinuteController.h
查看文件 @
fb3f3ce
...
@@ -7,10 +7,6 @@
...
@@ -7,10 +7,6 @@
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 三分钟即刻入睡VC(哄睡界面、Unity界面)
/// 三分钟即刻入睡VC(哄睡界面、Unity界面)
@interface
ThreeMinuteController
:
UIViewController
@interface
ThreeMinuteController
:
UIViewController
@end
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/FallAsleep/ThreeMinuteController.m
查看文件 @
fb3f3ce
...
@@ -7,8 +7,10 @@
...
@@ -7,8 +7,10 @@
#import "ThreeMinuteController.h"
#import "ThreeMinuteController.h"
#import "AppDelegate.h"
#import "AppDelegate.h"
#import <UnityFramework/UnityFramework.h>
@interface
ThreeMinuteController
()
@interface
ThreeMinuteController
()
<
UnityFrameworkListener
>
@property
(
nonatomic
,
strong
)
UnityFramework
*
ufw
;
@end
@end
@implementation
ThreeMinuteController
@implementation
ThreeMinuteController
...
@@ -18,9 +20,7 @@
...
@@ -18,9 +20,7 @@
self
.
view
.
backgroundColor
=
DSBlack
;
self
.
view
.
backgroundColor
=
DSBlack
;
// 加载unity
[
self
showUnityView
];
AppDelegate
*
appDelegate
=
(
AppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
;
[
appDelegate
showUnityView
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
exitCoaxSleep
)
name
:
ExitCoaxSleep
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
exitCoaxSleep
)
name
:
ExitCoaxSleep
object
:
nil
];
}
}
...
@@ -42,4 +42,50 @@
...
@@ -42,4 +42,50 @@
return
YES
;
return
YES
;
}
}
#pragma mark - Unity
UnityFramework
*
UnityFrameworkLoad
(
void
)
{
NSString
*
bundlePath
=
[[[
NSBundle
mainBundle
]
bundlePath
]
stringByAppendingString
:
@"/Frameworks/UnityFramework.framework"
];
NSBundle
*
bundle
=
[
NSBundle
bundleWithPath
:
bundlePath
];
if
([
bundle
isLoaded
]
==
false
)
{
[
bundle
load
];
}
UnityFramework
*
ufw
=
[
bundle
.
principalClass
getInstance
];
if
(
!
[
ufw
appController
])
{
[
ufw
setExecuteHeader
:
&
_mh_execute_header
];
}
return
ufw
;
}
-
(
bool
)
unityIsInitialized
{
return
[
self
ufw
]
&&
[[
self
ufw
]
appController
];
}
extern
int
gArgc
;
extern
char
**
gArgv
;
-
(
void
)
initUnity
{
// unity如果初始化了,首先需要卸载unity
if
([
self
unityIsInitialized
])
{
[
DSProgressHUD
showDetailInfo
:
@"Unity already initialized,please unload unity first"
];
return
;
}
[
self
setUfw
:
UnityFrameworkLoad
()];
[[
self
ufw
]
setDataBundleId
:
"com.unity3d.framework"
];
[[
self
ufw
]
registerFrameworkListener
:
self
];
[[
self
ufw
]
runEmbeddedWithArgc
:
gArgc
argv
:
gArgv
appLaunchOpts
:
nil
];
}
-
(
void
)
showUnityView
{
[
self
initUnity
];
[
self
.
ufw
showUnityWindow
];
}
#pragma mark - UnityFrameworkListener
-
(
void
)
unityDidUnload
:
(
NSNotification
*
)
notification
{
DSLog
(
@"unityDidUnload"
);
[[
self
ufw
]
unregisterFrameworkListener
:
self
];
[
self
setUfw
:
nil
];
[
DSDelegateWindow
makeKeyAndVisible
];
}
@end
@end
DreamSleep/DreamSleep/Class/Start/Root/AppDelegate.h
查看文件 @
fb3f3ce
...
@@ -6,16 +6,8 @@
...
@@ -6,16 +6,8 @@
//
//
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#import <UnityFramework/UnityFramework.h>
@interface
AppDelegate
:
UIResponder
<
UIApplicationDelegate
,
UnityFrameworkListener
>
@interface
AppDelegate
:
UIResponder
<
UIApplicationDelegate
>
@property
(
strong
,
nonatomic
)
UIWindow
*
window
;
@property
(
strong
,
nonatomic
)
UIWindow
*
window
;
#pragma mark - Unity
@property
(
nonatomic
,
strong
)
NSDictionary
*
appLaunchOpts
;
@property
(
nonatomic
,
strong
)
UnityFramework
*
ufw
;
/// 显示unity
-
(
void
)
showUnityView
;
@end
@end
DreamSleep/DreamSleep/Class/Start/Root/AppDelegate.m
查看文件 @
fb3f3ce
...
@@ -158,55 +158,4 @@
...
@@ -158,55 +158,4 @@
}
}
}
}
#pragma mark - Unity
UnityFramework
*
UnityFrameworkLoad
(
void
)
{
NSString
*
bundlePath
=
[[[
NSBundle
mainBundle
]
bundlePath
]
stringByAppendingString
:
@"/Frameworks/UnityFramework.framework"
];
NSBundle
*
bundle
=
[
NSBundle
bundleWithPath
:
bundlePath
];
if
([
bundle
isLoaded
]
==
false
)
{
[
bundle
load
];
}
UnityFramework
*
ufw
=
[
bundle
.
principalClass
getInstance
];
if
(
!
[
ufw
appController
])
{
[
ufw
setExecuteHeader
:
&
_mh_execute_header
];
}
return
ufw
;
}
-
(
bool
)
unityIsInitialized
{
return
[
self
ufw
]
&&
[[
self
ufw
]
appController
];
}
extern
int
gArgc
;
extern
char
**
gArgv
;
-
(
void
)
initUnity
{
// unity如果初始化了,首先需要卸载unity
if
([
self
unityIsInitialized
])
{
[
DSProgressHUD
showDetailInfo
:
@"Unity already initialized,please unload unity first"
];
return
;
}
[
self
setUfw
:
UnityFrameworkLoad
()];
[[
self
ufw
]
setDataBundleId
:
"com.unity3d.framework"
];
[[
self
ufw
]
registerFrameworkListener
:
self
];
[[
self
ufw
]
runEmbeddedWithArgc
:
gArgc
argv
:
gArgv
appLaunchOpts
:
self
.
appLaunchOpts
];
}
-
(
void
)
showUnityView
{
[
self
initUnity
];
[
self
.
ufw
showUnityWindow
];
}
#pragma mark - UnityFrameworkListener
-
(
void
)
unityDidUnload
:
(
NSNotification
*
)
notification
{
DSLog
(
@"unityDidUnload"
);
[[
self
ufw
]
unregisterFrameworkListener
:
self
];
[
self
setUfw
:
nil
];
[
self
.
window
makeKeyAndVisible
];
}
-
(
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
@end
DreamSleep/TapiOS/Classes/UI/UnityAppController+ViewHandling.mm
查看文件 @
fb3f3ce
...
@@ -143,10 +143,11 @@ extern bool _unityAppReady;
...
@@ -143,10 +143,11 @@ extern bool _unityAppReady;
NSAssert
(
_rootView
!=
nil
,
@"_rootView should be inited at this point"
);
NSAssert
(
_rootView
!=
nil
,
@"_rootView should be inited at this point"
);
NSAssert
(
_rootController
!=
nil
,
@"_rootController should be inited at this point"
);
NSAssert
(
_rootController
!=
nil
,
@"_rootController should be inited at this point"
);
[
UIView
setAnimationsEnabled
:
NO
];
#pragma mark - 3、修复首次加载unity页面出现主APP启动页面问题
ShowSplashScreen
(
_window
);
// [UIView setAnimationsEnabled: NO];
// ShowSplashScreen(_window);
// make window visible only after we have set up initial controller we want to show
// make window visible only after we have set up initial controller we want to show
[
_window
makeKeyAndVisible
];
//
[_window makeKeyAndVisible];
#if UNITY_SUPPORT_ROTATION
#if UNITY_SUPPORT_ROTATION
// to be able to query orientation from view controller we should actually show it.
// to be able to query orientation from view controller we should actually show it.
...
...
DreamSleep/TapiOS/Classes/UnityAppController.mm
查看文件 @
fb3f3ce
...
@@ -131,6 +131,7 @@ NSInteger _forceInterfaceOrientationMask = 0;
...
@@ -131,6 +131,7 @@ NSInteger _forceInterfaceOrientationMask = 0;
UnitySetPlayerFocus
(
1
);
UnitySetPlayerFocus
(
1
);
#pragma mark - 1、解决手机开启静音模式下播放没有声音问题
AVAudioSession
*
audioSession
=
[
AVAudioSession
sharedInstance
];
AVAudioSession
*
audioSession
=
[
AVAudioSession
sharedInstance
];
[
audioSession
setCategory
:
AVAudioSessionCategoryPlayback
error
:
nil
];
[
audioSession
setCategory
:
AVAudioSessionCategoryPlayback
error
:
nil
];
[
audioSession
setActive
:
YES
error
:
nil
];
[
audioSession
setActive
:
YES
error
:
nil
];
...
@@ -387,6 +388,7 @@ extern "C" void UnityCleanupTrampoline()
...
@@ -387,6 +388,7 @@ extern "C" void UnityCleanupTrampoline()
_didResignActive
=
false
;
_didResignActive
=
false
;
}
}
#pragma mark - 2、自定义
// 创建原生页面和控件,自己控制唤起Unity时机
// 创建原生页面和控件,自己控制唤起Unity时机
-
(
void
)
startSelfIOSView
-
(
void
)
startSelfIOSView
{
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论