If you want to add Components to your Actor in EUW, your scripts will be something like this.
In my situation, this will not work as it is expected.
I added Box Component, and it appears in Scene, but not in details panel.
And, If I move the Actor, the box will disapper.
There is a reason for this, but it’s tricky.
If You copy the actor and paste it into text editor, You can get something like this.
Begin Map
Begin Level
Begin Actor Class=/Script/Engine.Actor Name=Actor_0 Archetype=/Script/Engine.Actor'/Script/Engine.Default__Actor'
Begin Object Class=/Script/Engine.SceneComponent Name="DefaultSceneRoot"
End Object
Begin Object Class=/Script/Engine.BoxComponent Name="BoxComponent_0"
End Object
Begin Object Name="DefaultSceneRoot"
bVisualizeComponent=True
CreationMethod=Instance
End Object
Begin Object Name="BoxComponent_0"
AreaClass=Class'"/Script/NavigationSystem.NavArea_Obstacle"'
AttachParent=SceneComponent'"DefaultSceneRoot"'
CreationMethod=UserConstructionScript
End Object
RootComponent=SceneComponent'"DefaultSceneRoot"'
ActorLabel="Actor"
InstanceComponents(0)=SceneComponent'"DefaultSceneRoot"'
End Actor
End Level
Begin Surface
End Surface
End Map
BoxComponent has a property called “CreationMethod”. By default,the value will be “userConstructionScript”, when the component was made via blueprints.
That is causing a problem.
If I change the value to “Instance” in text editor, and paste back to UE, the components will show up correctly.
So, I have to change “CreationMethod” from “UserConstructionScript” to “Instance”, when I add component in Blueprint.
The way I found is creat a cutsom blueprint node by using c++.
C++ offers a functionaily to do that. Here is a sample of my custom blueprint.
Custom_BP_LibraryBPLibrary.cpp
#include "Custom_BP_LibraryBPLibrary.h"
#include "Custom_BP_Library.h"
#include "ComponentInstanceDataCache.h"
UActorComponent* UCustom_BP_LibraryBPLibrary::SetCreationMethod(UActorComponent* ActorComponent, EComponentCreationMethod method)
{
if (ActorComponent != nullptr) {
ActorComponent->CreationMethod = method;
}
return ActorComponent;
}
Custom_BP_LibraryBPLibrary.h
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Custom_BP_LibraryBPLibrary.generated.h"
UCLASS()
class UCustom_BP_LibraryBPLibrary : public UBlueprintFunctionLibrary
{
GENERATED_UCLASS_BODY()
UFUNCTION(BlueprintCallable, Category = "Custom_BP_LibraryTesting")
static UActorComponent* SetCreationMethod(UActorComponent* ActorComponent, EComponentCreationMethod method);
};
If I put this node after adding component, now I can add any components to Actor by using this Editor Utility Widget.
But there is another small problem left.
If I add component to my Actor, sometimes the component will not show up in details panel.
Refreshing details panel by selecting other Actor makes it show up.
So the script is surely working, but something is going wrong.
I encounterd very complicated process through fixing those issues, and something remain unsolved.
I think there must be things that need to be fixed.
what do you think?
Any help would be greatly appreciated.