Unreal Engine 4
このガイドでは、Hive SDKをインストールした後に実行するタスクについて説明します。
自動回転画面機能の設定¶
画面の向きを横向きと縦向きの両方に設定する場合、以下の設定が必要です。
アンドロイド¶
Androidアプリのビルドでは、画面の向きを横向きと縦向きの両方に設定し、自動回転機能が正しく動作するようにするには、以下のコードを修正する必要があります。 
<
- /Engine/Build/Android/Java/src/com/epicgames/ue4/GameActivity.java.templateに移動します。
- HiveActivity.onConfigurationChaged()APIを追加します。- @Override public void onConfigurationChanged(Configuration newConfig) { HiveActivity.onConfigurationChanged(this, newConfig); // 追加 super.onConfigurationChanged(newConfig); // 向きを前方にする boolean bPortrait = newConfig.orientation == Configuration.ORIENTATION_PORTRAIT; nativeOnConfigurationChanged(bPortrait); }
iOS¶
iOSでは、追加の双方向設定が正しく機能するようにするために、Unreal EngineのIOSAppDelegate.cppファイルにおいて、画面回転に関連するメソッドapplication(_:supportedInterfaceOrientationsFor:)を実装する必要があります。このメソッドの戻り値は、ゲームに適用されるUIInterfaceOrientationMaskの値を返す必要があります。横向き専用のゲームはlandscapeを返し、縦向き専用のゲームはportraitを返し、横向きと縦向きを両方サポートするゲームはlandscapeとportraitの両方を返します。 
/Engine/Source/Runtime/ApplicationCore/Private/IOS/IOSAppDelegate.cppに以下のコードを追加してください。
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
  // TODO: Landscape-only game
  return UIInterfaceOrientationMaskLandscape;
  // TODO: Portrait-only game
  return UIInterfaceOrientationMaskPortrait;
  // TODO: Game supporting both landscape and portrait
  return UIInterfaceOrientationMaskAll;
}
Swift互換性の設定 (iOS)¶
iOS開発環境では、Unreal Engine 4とSwift言語の互換性を確保するために、以下のファイルに'Add'コメントでマークされた行を追加します(AddからAdd Endまで)。 
エンジン/ソース/プログラム/UnrealBuildTool/プロジェクトファイル/Xcode/XcodeProject.cs
    {
       Content.Append("\t\t\t\t\"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]\" = " + IOS_BUNDLE + ";" + ProjectFileGenerator.NewLine);
   }
   // Add
   if (ProjectFile != null)
   {
       Content.Append("\t\t\t\tSWIFT_VERSION = 5.0;" + ProjectFileGenerator.NewLine);
       Content.Append("\t\t\t\tSWIFT_OBJC_BRIDGING_HEADER = \"" + GamePath + "/dummy-Bridging-Header.h\";" + ProjectFileGenerator.NewLine);
   }
   // Add End
}
if (TVOSRunTimeVersion != null)
{
if (XcodeProjectFileGenerator.bGeneratingRunIOSProject)
{
   Content.Append("\t\t\t\tALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;"+ ProjectFileGenerator.NewLine); // Add
   Content.Append("\t\t\t\tINFOPLIST_FILE = \"" + IOSInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
   Content.Append("\t\t\t\tCODE_SIGN_ENTITLEMENTS = \"" + IOSEntitlementPath + "\";" + ProjectFileGenerator.NewLine);
}
Content.Append("\t\t\t\t\"INFOPLIST_FILE[sdk=macosx*]\" = \"" + MacInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
if (IOSRunTimeVersion != null)
{
   Content.Append("\t\t\t\tALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;"+ ProjectFileGenerator.NewLine); // Add
   Content.Append("\t\t\t\t\"INFOPLIST_FILE[sdk=iphoneos*]\" = \"" + IOSInfoPlistPath + "\";" + ProjectFileGenerator.NewLine);
   Content.Append("\t\t\t\t\"CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]\" = \"" + IOSEntitlementPath + "\";" + ProjectFileGenerator.NewLine);
}
Engine/Source/Programs/UnrealBuildTool/Platform/IOS/IOSToolChain.cs
    Result += " -Xlinker \\\"" + Path.GetDirectoryName(OutputFile.AbsolutePath) + "\\\"";
}
Result += " -Xlinker -rpath -Xlinker /usr/lib/swift";  // Add
Result += " -dead_strip";
Result += " -m" + GetXcodeMinVersionParam() + "=" + ProjectSettings.RuntimeVersion;
Result += " -Wl";
HIVEAppDelegate (iOS) の適用¶
iOS開発環境では、Swizzlingを使用してAppDelegateを修正し、Hive SDKを使用します。アプリの開始時に初期化ステップで以下のコードを追加してください。
////////////////////////////////////////////////////////////////
// Add IOSAppDelegate.h header
#if PLATFORM_IOS
#include "Runtime/ApplicationCore/Public/iOS/IOSAppDelegate.h"
#endif
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// AppDelegate additional 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)¶
Unreal Engine iOSとC++標準テンプレートライブラリとの互換性を確保するために、FMallocAnsiを次のように設定する必要があります。以下のコードをアプリプロジェクトの{YourProject}.Target.csファイルに追加してください。