C++에서 구현한 기능을 Blueprint에서 사용하게 만들기
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
UCLASS()
class TUTORIAL_API AMyActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyActor();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Damage")
int32 TotalDamage;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Damage")
float DamageTimeInSeconds;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Damage")
float DamagePerSecond;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Blueprint에서 사용이 가능하게 선언
UFUNCTION(BlueprintCallable, Category = "Damage")
void CalculateDPS();
virtual void PostInitProperties() override;
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
};
Blueprint에서 구현한 기능을 C++에서 사용하게 만들기
방법1) BlueprintImplementableEvent
UFUNCTION(BlueprintImplementableEvent, Category = "Damage")
void CallFromCpp(); // 내부는 Blueprint에서 만들기에 내부는 안만들어도 됨.
방법2) BlueprintNativeEvent
UFUNCTION(BlueprintNativeEvent, Category = "Damage")
void CallFromCpp();
virtual void CallFromCpp_Implementation();
void AMyActor::CallFromCpp_Implementation()
{
UE_LOG(LogTemp, Warning, TEXT("CallFromCpp_Implementation"));
}