Unreal Engine 5
本指南解释了安装Hive SDK后需要执行的任务。
设置屏幕自动旋转功能¶
在将屏幕方向设置为两个方向(横屏和竖屏)时,需要以下配置。
安卓¶
要使屏幕自动旋转功能在 Android 应用程序构建中正确工作,当设置屏幕方向为两种方向(横向和纵向)时,需要进行以下代码修改。
- 导航到 /Engine/Build/Android/Java/src/com/epicgames/unreal/GameActivity.java.template。
- 添加
HiveActivity.onConfigurationChanged()API。@Override public void onConfigurationChanged(Configuration newConfig) { HiveActivity.onConfigurationChanged(this, newConfig); // 添加 super.onConfigurationChanged(newConfig); // 转发方向 boolean bPortrait = newConfig.orientation == Configuration.ORIENTATION_PORTRAIT; nativeOnConfigurationChanged(bPortrait); }
iOS¶
对于 Hive SDK Unreal Engine 5 iOS,不需要额外的屏幕自动旋转配置。
更改 Xcode 构建 (iOS)¶
要应用 Hive SDK v4,您需要将 Xcode 构建系统更改为旧版构建。如下面所示,在左侧面板的 项目设置 > 平台 > Xcode 项目 部分取消选中 最新 Xcode。 
应用 HIVEAppDelegate (iOS)¶
在 iOS 开发环境中使用 Hive SDK,请使用 Swizzling 修改 AppDelegate。在应用启动时的初始化阶段添加以下代码。
////////////////////////////////////////////////////////////////
// Add IOSAppDelegate.h header
#if PLATFORM_IOS
#include "Runtime/ApplicationCore/Public/iOS/IOSAppDelegate.h"
#endif
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// Additional AppDelegate code
#if PLATFORM_IOS
UIApplication * dummyApplication = [UIApplication sharedApplication];
Class clzHIVEAppDelegate = NSClassFromString(@"HIVEAppDelegate");
SEL selApplicationDidFinishLaunchingWithOptions = NSSelectorFromString(@"application:didFinishLaunchingWithOptions:");
if( clzHIVEAppDelegate != nil && [clzHIVEAppDelegate respondsToSelector:selApplicationDidFinishLaunchingWithOptions] ) {
NSMethodSignature *method = [clzHIVEAppDelegate methodSignatureForSelector:selApplicationDidFinishLaunchingWithOptions];
if (method != nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:method];
[invocation setSelector:selApplicationDidFinishLaunchingWithOptions];
[invocation setTarget:clzHIVEAppDelegate];
[invocation setArgument:(void*)&dummyApplication atIndex:2];
NSDictionary *localLaunchOptions = [IOSAppDelegate GetDelegate].launchOptions;
if( localLaunchOptions != nil ) {
[invocation setArgument:(void*)&localLaunchOptions atIndex:3];
}
[invocation invoke];
}
}
#endif
////////////////////////////////////////////////////////////////
设置 FmallocAnsi (iOS)¶
若使用 HIVESDK/Public/CPP 路径的 C++ 接口,为兼容 Unreal Engine iOS 和 C++ 标准模板库,需要按如下方式设置 FMallocAnsi。请在游戏应用项目的 {YourProject}.Target.cs 文件中添加以下代码。
Warning
- 使用 HIVESDK/Public/CPP 路径的 C++ 接口时:需要设置 FmallocAnsi
- 使用 HIVESDK/Public 路径的 Unreal Engine 专用接口时:不需要设置 FmallocAnsi
Note
HIVESDK/Public/CPP 路径的 C++ 接口今后计划 deprecated,因此建议使用 HIVESDK/Public 路径的 Unreal Engine 专用接口。