Move defaults change to constructor instead of OnRegister, fix SetIsVizualisationComponent only being available in editor builds

This commit is contained in:
Steve Streeting 2021-09-13 18:09:25 +01:00
parent 44dad3b505
commit 1a1b66c3e9
2 changed files with 9 additions and 6 deletions

View File

@ -4,16 +4,18 @@
#include "StevesEditorVisComponent.h" #include "StevesEditorVisComponent.h"
#include "StevesDebugRenderSceneProxy.h" #include "StevesDebugRenderSceneProxy.h"
void UStevesEditorVisComponent::OnRegister() UStevesEditorVisComponent::UStevesEditorVisComponent(const FObjectInitializer& ObjectInitializer)
: UPrimitiveComponent(ObjectInitializer)
{ {
Super::OnRegister();
// set up some constants // set up some constants
SetCollisionEnabled(ECollisionEnabled::NoCollision); PrimaryComponentTick.bCanEverTick = false;
SetCastShadow(false); SetCastShadow(false);
#if WITH_EDITORONLY_DATA
SetIsVisualizationComponent(true); SetIsVisualizationComponent(true);
#endif
SetHiddenInGame(true); SetHiddenInGame(true);
AlwaysLoadOnClient = false; AlwaysLoadOnClient = false;
bIsEditorOnly = true;
} }

View File

@ -58,7 +58,7 @@ struct FStevesEditorVisCircle
* If you want to, you can add this to your Blueprints too. This component automatically marks itself as "visualisation * If you want to, you can add this to your Blueprints too. This component automatically marks itself as "visualisation
* only" so shouldn't have a runtime impact. * only" so shouldn't have a runtime impact.
*/ */
UCLASS(ClassGroup="Debug", hidecategories=(Collision,Object,LOD,Lighting,TextureStreaming), meta=(DisplayName="Steves Editor Visualisation", BlueprintSpawnableComponent)) UCLASS(ClassGroup="Debug", hidecategories=(Collision,Physics,Object,LOD,Lighting,TextureStreaming), meta=(DisplayName="Steves Editor Visualisation", BlueprintSpawnableComponent))
class STEVESUEHELPERS_API UStevesEditorVisComponent : public UPrimitiveComponent class STEVESUEHELPERS_API UStevesEditorVisComponent : public UPrimitiveComponent
{ {
GENERATED_BODY() GENERATED_BODY()
@ -67,7 +67,8 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FStevesEditorVisCircle> Circles; TArray<FStevesEditorVisCircle> Circles;
virtual void OnRegister() override; UStevesEditorVisComponent(const FObjectInitializer& ObjectInitializer);
virtual FPrimitiveSceneProxy* CreateSceneProxy() override; virtual FPrimitiveSceneProxy* CreateSceneProxy() override;
virtual FBoxSphereBounds CalcBounds(const FTransform& LocalToWorld) const override; virtual FBoxSphereBounds CalcBounds(const FTransform& LocalToWorld) const override;
/// Needs to update on transform since proxy is detached /// Needs to update on transform since proxy is detached