Download

C++ 4.16 Transition Guide

From the release notes:

“The TargetRules.SetupBinaries() callback has been deprecated. Instead of overriding this, targets may override the launch module through the “LaunchModuleName” property in their constructor, and add extra modules to the “ExtraModuleNames” field on the TargetRules object itself.”

I’m having this deprecation warning but I can’t seem to figure out how i should change it to the new standard:



public override void SetupBinaries(TargetInfo Target,
		ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
		ref List<string> OutExtraModuleNames)
               	{
		OutExtraModuleNames.Add("VR_Game");
}

Any suggestions?

EDIT: Created a new 4.16 project and checked how it is generated and from there I found the correct way.

From the above code I changed it to:



public VR_GameTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
ExtraModuleNames.Add("VR_Game");
}


I was using an FStreamableManager property in GameInstance class to load assets dynamically. This seems to no longer work in 4.16. I get the following error.



UCLASS()
class CCAM_API UMainGameInstance : public UPlatformGameInstance
{
	GENERATED_BODY()

public:
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Data")
	UWeaponData* WeaponData = nullptr;

	UPROPERTY(BlueprintReadOnly, Category = "Maps")
	FStreamableManager Assets;
};




C:/UEProjects/CCam/Source/CCam/GamePlay/MainGameInstance.h(23): error : Unrecognized type 'FStreamableManager' - type must be a UCLASS, USTRUCT or UENUM


This was working in 4.15. How do I fix this? Tried adding a header for StreamableManger no luck.

Just remove the UPROPERTY line above it. It’s no longer a reflected type, but since it had nothing exposed to blueprints anyway, this shouldn’t have any effect on your project.

How to fix such errors? FIOSystem was completely removed.
*
‘GNewAsyncIO’: undeclared identifier
‘FIOSystem’: is not a class or namespace name
*

Hi, I have the following issue since upgrading my project to 4.16, using Visual C++ 2015: when the Unreal Editor is launched, the build from within Visual C++ (CTRL+SHIFT+B) fails with strange errors (see below). If I close the Unreal Editor then I can compile fine from Visual C++. I didn’t have that problem with 4.15, I could build either from VC++ or Unreal when both were open.

Error (active) identifier “FDrawingPolicyRenderState” is undefined

e:\UE_4.16\Engine\Source\Runtime\Engine\Public\SceneManagement.h 1560
Error Failed to produce item: mygame-Win64-DebugGame.lib

Error MSB3075 The command “E:\UE_4.16\Engine\Build\BatchFiles\Build.bat mygame Win64 DebugGame “E:\Unreal Projects\mygame \mygame .uproject” -waitmutex” exited with code 5. Please verify that you have sufficient rights to run this command.

Hello everyone! It’s already written, but I want to collect all in one heap and show you this visually.
How to transition your C ++ project from 4.15 to new features 4.16 and get rid of the warnings about of deprecated functions.

When RC is your project name:

&stc=1

&stc=1

&stc=1

Enjoy!)

Could you or someone show the complete and working target.cs file? I can’t get anything to work with 4.16, it only throws compile errors. :frowning:

Edit: Well I’ve solved most critical errors, but whats up with this warning:

“Warning Module constructors should take a ReadOnlyTargetRules argument (rather than a TargetInfo argument) and pass it to the base class constructor from 4.15 onwards. Please update the method signature.”

(every target file throws this warning)

TMaps with custom structs (as key) now need to explicitly implement *GetTypeHash * or supply custom key funcs for the struct. Previously it was sufficient if your parent struct implemented it, now it has to be defined for each struct it seems.

For reference here’s a snippet from FGameplayTag:


/** Used so we can have a TMap of this struct */
FORCEINLINE friend uint32 GetTypeHash(const FGameplayTag& Tag)	{ return ::GetTypeHash(Tag.TagName); }

For reference (and easy googling!) here’s the actual error: TMap must have a hashable KeyType unless a custom key func is provided.

I have these now:


using UnrealBuildTool;
using System.Collections.Generic;

public class BrickSpaceTarget : TargetRules
{
	public BrickSpaceTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Game;
		ExtraModuleNames.Add("BrickSpace");
	}
}


using UnrealBuildTool;
using System.Collections.Generic;

public class BrickSpaceEditorTarget : TargetRules
{
	public BrickSpaceEditorTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Editor;
		ExtraModuleNames.Add("BrickSpace");
		ExtraModuleNames.Add("BrickSpaceEditor");
	}
}

They’ve been simplified quite a bit in 4.16 :smiley:

That’s a great reply. Unfortunately it seems that the error “identifier “FDrawingPolicyRenderState” is undefined” still pops from time to time. What I found out is that the error is only intellisense error. It doesn’t affect the compilation.

Thanks a lot for sharing! I don’t have any editor module entry under the game module in my editor target file tho, but it seems to work anyways :o

If you leave it out, only the game module will be compiled when building for development editor config.
Of course if your game doesn’t have an editor module, you can’t really compile one :smiley:

Hi guys! I’m having an issue with asset registry after upgrading to 4.16.

I have this little method that loads the assetdata for my game playable maps:



void UMyStatics::GetPlayableMapAssets(TArray<FAssetData>& PlayableMaps)
{
	PlayableMaps.Empty();

	FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
	IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();

	TArray<FString> RootPaths;
	FPackageName::QueryRootContentPaths(RootPaths);
	RootPaths.Remove(TEXT("/Engine/"));
	RootPaths.Remove(TEXT("/Paper2D/"));

	for (FString Path : RootPaths)
	{
		TArray<FString> Paths;
		Paths.Add(Path.Append(TEXT("Maps/")));
		AssetRegistry.ScanPathsSynchronous(RootPaths, true);

		FARFilter ARFilter;
		ARFilter.ClassNames.Add(UWorld::StaticClass()->GetFName());
		TArray<FName> OldNames = FLinkerLoad::FindPreviousNamesForClass(UWorld::StaticClass()->GetPathName(), false);
		ARFilter.ClassNames.Append(OldNames);
		ARFilter.bRecursivePaths = true;
		ARFilter.bRecursiveClasses = false;

		TArray<FAssetData> AssetList;
		if (AssetRegistry.GetAssets(ARFilter, AssetList))
		{
			for (int32 i = 0; i < AssetList.Num(); i++)
			{
				bool bPlayable = false;
				if (AssetList*.GetTagValue<bool>(FName("bIsPlayable"), bPlayable) && bPlayable)
				{
					PlayableMaps.Add(AssetList*);
				}
			}
		}
	}	
}


This was working perfectly fine with 4.14 and 4.15.
Today I upgraded my project to 4.16 and now the asset registry is giving me an array with all it’s entries duplicated.
For example, if my maps are “Map1”, “Map2”] then AssetRegistry.GetAssets() gives me “Map1”, “Map1”, “Map2”, “Map2”]

Just upgraded Able to 4.16 and it wasn’t too crazy (4.15 was WAYYYY worse). Change your Build.cs as others have shown, and fix up any now deprecated method calls.

@Sveitar, change your Add to AddUnique and you can filter out duplicate entries at that level. Granted the behavior probably shouldn’t have changed, but still - at least that will keep you going.



PlayableMaps.AddUnique(AssetList*);


My Wwise audio plugin is using a line that throws an error:


public static string GetDefaultVersionFileName()
    {
        return Path.Combine(UnrealBuildTool.UnrealBuildTool.EngineDirectory.FullName, "Build" + Path.DirectorySeparatorChar + "Build.version");
    }

It says that “UnrealBuildTool.UnrealBuildTool” is unaccessible due to its protection level"

It also throws the error that .EngineDirectory is not valid

I cannot find any documentation on the UnlrealBuildTool stuff though; it seems like they may have made it protected in 4.16? Is there a more preferred way to access the engine directory?

I’ve no idea what calls that method you have there, but I’m using this in another place in Build.cs:
Path.GetFullPath(BuildConfiguration.RelativeEnginePath)
Maybe it helps?

Using that throws the following error:

error CS0120: An object reference is required for the non-static field, method, or property ‘UnrealBuildTool.ModuleRules.BuildConfiguration.get’

Additionally, I am getting the error that @v.s. was getting here:

I think it might be related to this function not getting the correct engine directory. Thanks for your help

Edit: I was able to fix the BuildConfiguration.RelativeEnginePath error by making the function declaration not static. I am not a great coder. It works great.

However, the FIOSystem errors persist. I do not see any documentation that it has been removed, so I am not sure what is causing it.

According to a post over at Wwise, somebody had a similar issue when upgrading to 4.14:

https://www.audiokinetic.com/qa/2917/building-editor-builds-fails-with-latest-plugin-from-launcher

So it seems to be an error that crops up on upgrades, not just to 4.16 in particular

Edit 2: Looking at their source code on github, it does indeed look like IOBase.h, which contained FIOSystem, has been removed from the engine. So I’m not sure what to do about that!

I have not migrated yet from 4.15, but one good way to solve many of these transition errors is by creating a new 4.16 project using template. Check the syntax and adjust accordingly.

Better yet, create the same template in 4.15 and 4.16 and use a diff tool on the source.

I still get 2 of these warnings during UAT when building from the project launcher:

"
UnrealBuildTool: h:\Unreal Projects\MyGame\Source\MyGame\MyGame.Build.cs(6,12) : warning CS0618: ‘UnrealBuildTool.ModuleRules.ModuleRules()’ is obsolete: ‘Please change your module constructor to take a ReadOnlyTargetRules parameter, and pass it to the base class constructor (eg. “MyModuleRules(ReadOnlyTargetRules Target) : base(Target)”).’

UnrealBuildTool: H:\Unreal Projects\MyGame\Source\MyGame\MyGame.Build.cs: warning: Module constructors should take a ReadOnlyTargetRules argument (rather than a TargetInfo argument) and pass it to the base class constructor from 4.15 onwards. Please update the method signature.
"

This is what the target file looks like right now, but dosen’t seem to be correct.



using UnrealBuildTool;
using System.Collections.Generic;

public class MyGameTarget : TargetRules
{
	public MyGameTarget(TargetInfo Target) : base(Target)
    {
        Type = TargetType.Game;
        ExtraModuleNames.Add("MyGame");
        bUsesSteam = true;
	}