Hi all,
I’m trying to get live updates of a custom actor of mine working in the editor. Since Actors can’t tick in the editor, I’ve added a component to the actor which should be able to to. This component’s tick function will then call the necessary things to live-update the actor. Inspired by the CableComponent example I have a component which looks like:
UCLASS()
class UUpdateComponent : public USceneComponent
{
GENERATED_BODY()
public:
UUpdateComponent(const FObjectInitializer& PCIP);
void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
};
#include "UpdateComponent.h"
UUpdateComponent::UUpdateComponent (const FObjectInitializer& PCIP)
: Super(PCIP)
{
PrimaryComponentTick.bCanEverTick = true;
bTickInEditor = true;
bAutoActivate = true;
//bAutoRegister = true;
//PrimaryComponentTick.bStartWithTickEnabled = true;
//PrimaryComponentTick.TickGroup = TG_PrePhysics;
//SetMobility(EComponentMobility::Movable);
//SetupActorComponentTickFunction(&PrimaryComponentTick);
}
void UUpdateComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
UE_LOG(MyLog, Log, TEXT("UUpdateComponent::TickComponent"));
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
//Here is where I will update the owning actor
//GetAttachmentRootActor()->DoThing();
};
There’s some commented-out code in the constructor which I’ve been trying but none of it helped.
In the owning actor’s constructor, I do the following and nothing else:
root = PCIP.CreateDefaultSubobject<UUpdateComponent>(this, TEXT("Updater component"));
RootComponent = root;
I would expect that when I add one of these to the scene, I should see lots of “UUpdateComponent::TickComponent” beings logged to the output but instead I see none. If I go into Play-In-Editor mode I start seeing the updates but as soon as I drop back to normal editor mode, they stop. Strangely, at one point I had it working but I am now unable to reproduce it.
Given that I see ticks in the PIE mode, I believe that my tick function is correctly registered and I’ve set bTickInEditor. Does anyone have any idea what could be causing the tick not to be called or any way I can start to debug the problem?