Skip to content

Unreal Engine 5

This guide explains the tasks to perform after installing the Hive SDK.

Setting screen auto-rotation feature

When setting the screen orientation to both directions (landscape and portrait), the following configuration is required.

Android

To enable the screen auto-rotation feature to work correctly when setting the screen orientation to both directions (landscape and portrait) in an Android app build, the following code modifications are necessary.

  1. Navigate to /Engine/Build/Android/Java/src/com/epicgames/unreal/GameActivity.java.template.
  2. Add the HiveActivity.onConfigurationChanged() API.
    @Override
    public void onConfigurationChanged(Configuration newConfig)
    {
    HiveActivity.onConfigurationChanged(this, newConfig); // Add
    super.onConfigurationChanged(newConfig);
    
    
    // forward the orientation
    boolean bPortrait = newConfig.orientation == Configuration.ORIENTATION_PORTRAIT;
    nativeOnConfigurationChanged(bPortrait);
    }
    

iOS

No additional configuration for screen auto-rotation is required for Hive SDK Unreal Engine 5 iOS.

Changing Xcode build (iOS)

To apply Hive SDK v4, you need to change the Xcode build system to Legacy Build. As shown below, uncheck Latest Xcode in the Project Settings > Platform > Xcode Project section of the left panel.

Applying HIVEAppDelegate (iOS)

To use the Hive SDK in the iOS development environment, modify the AppDelegate using Swizzling. Add the following code during the initialization stage when the app starts.

////////////////////////////////////////////////////////////////
// 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
////////////////////////////////////////////////////////////////

Setting FmallocAnsi (iOS)

To ensure compatibility between Unreal Engine iOS and the C++ Standard Template Library, the FMallocAnsi setting is required as follows. Add the following code to the {YourProject}.Target.cs file of your app project.

public class YourProjectTarget : TargetRules
{
    public YourProjectTarget(TargetInfo Target) : base(Target)
    {  
        // Force ANSI allocator for the app client
        if(Target.Platform == UnrealTargetPlatform.IOS)
        {
            GlobalDefinitions.Add("FORCE_ANSI_ALLOCATOR=1");
        }
    }
}