UE4 C++调用蓝图方法

1.创建接口

2.声明接口方法: 

UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Item")
  void OnSelect();

3.继承接口:

#include "CharcterInterface.h"

class GAMEREADY_API ACharactorCode : public ACharacter, public ICharcterInterface

virtual void OnSelect_Implementation() override;

4.实现接口方法

void ACharactorCode::OnSelect_Implementation()
{
}
5.调用接口
 ICharcterInterface* hitActor = Cast(hitResult.GetActor());
 if (hitActor)
 {
  hitActor->Execute_OnSelect(hitResult.GetActor());
 }

你可能感兴趣的:(UE4)