So when this property is updated / changed in the editor, how would I know in the C++ class? IE, when the static mesh is changed I’d like to add a Static Mesh component.
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Components/SceneComponent.h"
#include "Part.generated.h"
UCLASS(Abstract, Blueprintable, ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class EDITOR_API UPart : public USceneComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UPart();
// Called when the game starts
virtual void BeginPlay() override;
// Called every frame
virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;
protected:
// All parts have a credit cost to purchase from the store
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Part Properties")
int32 CreditCost = 0;
// ...
// All parts have one single static mesh
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite, Category = "Part Properties")
UStaticMeshComponent * ObjectMesh;
};
These “Parts” will hopefully go together to build things, think the rockets in KSP, the “thing” I hope to be an actor.
So parts are components, the finished custom vehicles are Actors. At least that’s the idea.
Since this is a component, it’s my understanding that it CAN have sub components, like a static mesh, but when I subclass it with a Blueprint I don’t get the Component view like I would with an Actor.
Yeah components ‘can’ have sub-components since they can also use the ObjectInitializer constructor, but last time I tried to do that I had all manner of issues with it since a lot of the ActorComponents’ properties are set based on it’s owning ‘Actor’. I ended up adding the components to the owning Actor instead, though still as part of the Constructor.