Hi everyone!
I have a some little problem here. This is my code:
.h
UCLASS()
class PROJECTONE_API AHexGrid : public AActor
{
GENERATED_BODY()
public:
AHexGrid();
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class USceneComponent* GridSystem;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GridSettinds")
class UHexSpriteComponent* Hex;
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
//Construct script
virtual void OnConstruction(const FTransform& Transform) override;
};
.cpp
void AHexGrid::OnConstruction(const FTransform & Transform)
{
Super::OnConstruction( Transform );
//Hex = ConstructObject<UHexSpriteComponent>(UHexSpriteComponent::StaticClass(), this, TEXT("Name1"));
Hex = NewObject<UHexSpriteComponent>(this, UHexSpriteComponent::StaticClass(), TEXT("Comp_1"));
Hex->RegisterComponent();
Hex->AttachToComponent(GridSystem, FAttachmentTransformRules::KeepWorldTransform);
}
This component added in actor, but I cant modify his setting:
Whats wrong? Maybe I miss something?
P.S.
If I add this component from here:
AHexGrid::AHexGrid()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
GridSystem = CreateDefaultSubobject<USceneComponent>(TEXT("HexGrid"));
GridSystem->AttachToComponent(GetRootComponent(), FAttachmentTransformRules::KeepWorldTransform);
Hex = NewObject<UHexSpriteComponent>(this, UHexSpriteComponent::StaticClass(), TEXT("Comp_1"));
Hex->RegisterComponent();
Hex->AttachToComponent(GridSystem, FAttachmentTransformRules::KeepWorldTransform);
}
I can use his settings.