In Blueprint For loop, set nodes for TMap or TSet works like Add node.

Do I have to understand this intended?

You can download project files from :
https://github.com/cutycutyhyaline/UE4TMapAndTSetWithForLoop

Problem:

Here is a function. just Add number to TSet.

void ARep02GameModeBase::TSetTest(int32 InNumber, TSet<int32>& OutSet)
{
	OutSet.Add(InNumber);
}

With this, I made :

And run.

But, with TArray?

void ARep02GameModeBase::TArrayTest(int32 InNumber, TArray<int32>& OutArray)
{
	OutArray.Add(InNumber);
}

This frustrates me. Expecting consistency is too much?

Let’s dig more deeper.

This is Header:

// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "Rep02GameModeBase.generated.h"

/**
 * 
 */
UCLASS()
class REP02_API ARep02GameModeBase : public AGameModeBase
{
	GENERATED_BODY()

	public:

	UFUNCTION(BlueprintCallable, Category = "Reproduce")
	void TArrayTest(int32 InNumber, TArray<int32>& OutArray);

	UFUNCTION(BlueprintCallable, Category = "Reproduce")
	void TMapTest(int32 InNumber, TMap<int32, int32>& OutMap);

	UFUNCTION(BlueprintCallable, Category = "Reproduce")
	void TSetTest(int32 InNumber, TSet<int32>& OutSet);	
};

And CPP:

// Copyright Epic Games, Inc. All Rights Reserved.


#include "Rep02GameModeBase.h"

void ARep02GameModeBase::TArrayTest(int32 InNumber, TArray<int32>& OutArray)
{
	OutArray.Add(InNumber);
}

void ARep02GameModeBase::TMapTest(int32 InNumber, TMap<int32, int32>& OutMap)
{
	OutMap.Add(InNumber, InNumber);
}

void ARep02GameModeBase::TSetTest(int32 InNumber, TSet<int32>& OutSet)
{
	OutSet.Add(InNumber);
}

And BP:

I know what “&” symbol means in cpp.
But… this is ridiculus because it works too honestly:(

Workaround?

What I could think is to make new local variable, and assign it to reference parameter.
(And I have to be careful to not forget this -_-)

void ARep02GameModeBase::TMapTestFixed(int32 InNumber, TMap<int32, int32>& OutMap)
{
	TMap<int32, int32> NewMap;
	NewMap.Add(InNumber, InNumber);
	OutMap = NewMap;
}

void ARep02GameModeBase::TSetTestFixed(int32 InNumber, TSet<int32>& OutSet)
{
	TSet<int32> NewSet;
	NewSet.Add(InNumber);
	OutSet = NewSet;
}

Cooking Failed ;( – Fixed :)

ProcessResult.StdOut: LogOutputDevice: Error: begin: stack for UAT
ProcessResult.StdOut: LogOutputDevice: Error: === Handled ensure: ===
ProcessResult.StdOut: LogOutputDevice: Error:
ProcessResult.StdOut: LogOutputDevice: Error: Ensure condition failed: !FPackageName::IsShortPackageName(Path) [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/CoreUObject/Private/UObject/SoftObjectPath.cpp] [Line: 79]
ProcessResult.StdOut: LogOutputDevice: Error: Cannot create SoftObjectPath with short package name 'NoneNone'! You must pass in fully qualified package names
ProcessResult.StdOut: LogOutputDevice: Error: Stack:
ProcessResult.StdOut: LogOutputDevice: Error: [Callstack] 0x00007ffc46d818a9 UE4Editor-CoreUObject.dll!DispatchCheckVerify >() [D:\Build++UE4\Sync\Engine\Source\Runtime\Core\Public\Misc\AssertionMacros.h:164]

What I found in searching:

Specially, from https://answers.unrealengine.com/questions/944064/view.html :

“Hi! I encountered this issue today, and fixed it about 5 minutes ago, so my solution is fresh and will probably work for everyone. Although for those who do not have coding knowledge, I feel sorry, because I don’t see any other way to properly track it down without debugger attached. So:

  1. Run editor with debugger attached.
  2. Enter the game – above error occurs, it will point you to the SoftObjectPath.cpp, but there is no info, so go to the callstack, and search for call in the file BlueprintEditorUtils.cpp. This function there will have FProperty as input, if you hover over it with debugger attached, it will show you EXACTLY which variable is causing the issue. Write its name down.
  3. Go even deeper into the callstack down to the KismetCompiler.cpp. It must have gone through the function PropagateValuesToCDO. This method has UObject* InNewCDO as parameter, hover over it and write down the name of that variable.
  4. Restart UE editor, find that asset, and that specific variable. Renaming won’t work. I found that removing that variable completely, and adding brand new one WITH DIFFERENT NAME and manually replacing references missing after old one is removed fixes that error! Voila ๐Ÿ™‚

It’s possible to fix that without compiler, but UE callstack doesn’t give you any info about what asset and variable this is all about. So tracking down which asset causes that might take much longer.”

Maybe found?

Whooooaaaa

Fixed. Usually problem like this spend few days, but in this case, it was 30 min.

BP Nativization with WBP inherited: Unreal Engine seems to could not recognize inherited widget hierarchy from parent class

Summary

  • There is a parent WBP(Widget BluePrint class) with widget hierarchy that have NamedSlot.
  • There is a child WBP, inherited parent above.
  • In new WBP, you use child WBP as container of the other elements in widget hierarchy.
  • In this condition, if you package them with nativization, the elements under child WBP in widget hierarchy become invalid.
  • To avoid this, implement the appearance of WBP in the widget hierarchy of final child class.
Setting

In PIE

Packaged with Nativization (Inclusive)
ButtonA is null!

Download project files

You can download these project files from:
https://github.com/cutycutyhyaline/UE4NativizationSurvivalLog001

When you inherit WBP with widget hierarchy

Here is an WBP with NamedSlot. Let’s call this as WBP_Parent.

WBP_Parent

If you make new WBP by inheriting WBP_Parent, you can see like this.

WBP_Child_A_UsingWidgetHierarchyOfParent

In Hierarchy tab, there is nothing except name of new WBP.
But you can still see the elements of Parent in designr view at center of editor.

But, what if we add new stuffs in Hierarchy tab?

WBP_Child_B_WidgetHierarchyOverwrited
It has an warning message, but it works.

As you see, we got warning message in Compiler Results ๐Ÿ˜ฆ

"This widget WBP_Child_B_WidgetHierarchyOverwrited and parent class widget WBP_Parent both have a widget hierarchy, which is not supported. Only one of them should have a widget tree."

“widget tree” in message means widget hierarchy. In precise, WidgetTree is inner class name of widget hierarchy.

OK. Anyway it works now, based on overwritied Widget Hierarchy.

Let’s see difference of these in more detail.

Settings to reproduce problem

Here is our main UI.

WBP_Hud
Widget Hierarchy in WBP_Hud

I placed WBP_Child_A_UsingWidgetHierarchyOfParent at upper line, with containing ButtonA
As like, I placed WBP_Child_B_WidgetHierarchyOverwrited at next line, with containing ButtonB.

I added some graph, to check each buttons are valid, and if they are null.
If they are valid, it change text of buttons, from “NotValidYet” to “YES! I AM VALID!”

Event Graph in WBP_Hud

We need to add this to game viewport.

BP_GameMode

In world setting, let’s change GameMode as BP_GameMode. Then, when we run in PIE, you can see this. Text of All buton changed to “YES! I AM VALID!”.

But, If we package this with nativization setting as Inclusive…

You can see this as you saw at summary.

WBP without compile warning message failed to show it’s child button as valid.
On the other hand, WBP got compile waring message, succeed to show it’s child as valid.

Conclusion

When WBP is nativized, unreal engine seems to could not recognize inherited widget hierarchy from parent class at completely.

If you want to avoid this, do not consist the appearance of WBP (Widget Hierarchy) in parent classes.

See also: BP – Nativizing a UMG widget hierarchy in which a child widget of another widget BP type has the “Is Variable” box unchecked will result in a crash at runtime. This was made me almost killed, too.

You can download these project files from:
https://github.com/cutycutyhyaline/UE4NativizationSurvivalLog001
I said twice because it’s important.