Kismet库

蓝图方法cpp使用

例:打LOG:Print String

蓝图节点的鼠标tips:Target is Kismet System Library

#include "Runtime/Engine/Classes/Kismet/KismetSystemLibrary.h"
UKismetSystemLibrary::PrintString(this, s) //KismetSystemLibrary 继承UObject

C++打LOG

DEFINE_LOG_CATEGORY_STATIC(LogName, Log, All); //.cpp文件声明LOG。注:LogName不能重,Log是个枚举,All是个枚举
UE_LOG(LogName, Log, TEXT("abc %s"),s);//可以像Printf样打印出
DECLARE_LOG_CATEGORY_EXTERN(AAAAA, Log, All); //在.h文件声明LOG
DEFINE_LOG_CATEGORY(AAAAA);//在.cpp文件使用
#include "Engine/Engine.h"
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("%s %f"), *Msg, Value));//引擎打LOG 注意-1 这个key可以用来当消息池索引

蓝图 C++ 互调

BlueprintCallable

UFUNCTION(BlueprintCallable, Category = "test")

void SendMsg(FString msg);//供蓝图调用的C++函数

BlueprintImplementableEvent

UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "ReceiveEvent"))

void ReceiveEvent(const FString& message);//蓝图实现函数供C++调用

参考Actor BeginPlay:

meta=(DisplayName="BeginPlay")

void ReceiveBeginPlay

在C++ BeginPlay里调用ReceiveBeginPlay

BlueprintPure

UFUNCTION(BlueprintPure, Category = "TAMediator") //蓝图输出 绿色

BlueprintNativeEvent

UFUNCTION(BlueprintNativeEvent) //本函数可用C++或蓝图实现

void fun1();//蓝图覆写函数

virtual void fun1_Implementation();//UHT生成 c++要重写的函数

C++实现蓝图接口

UINTERFACE(Category = "My Interface", BlueprintType, meta = (DisplayName = "My Interface"))
class MYMODULE_API UMyInterface : public UInterface {
GENERATED_UINTERFACE_BODY()
}; class MYMODULE_API IMyInterface {
GENERATED_IINTERFACE_BODY()
public:
UFUNCTION(BlueprintCallable)
virtual void fun1();//Error UFUNCTION(BlueprintCallable)
void fun1();//Error UFUNCTION(BlueprintNativeEvent)
void fun1();//蓝图可覆写 /// My Initialization Interface.
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
void OnInitialized(const AMyActor* Context);// 蓝图可覆写可调用 UFUNCTION(BlueprintImplementableEvent)
void Death();//True 在蓝图内以事件呈现
};

C++内调用 OnInitialized:

const auto &Interface = Cast<IMyInterface>(Actor);
if (Interface) {
Interface->Execute_OnInitialized(Actor,Context);
}
// Else, Execute Interface on Blueprint layer instead:
if (Actor->GetClass()->ImplementsInterface(UMyInterface::StaticClass())) {
IMyInterface::Execute_OnInitialized(Actor,Context);
}

相关网址

https://wiki.unrealengine.com/index.php?title=Interfaces_in_C%2B%2B

https://blog.csdn.net/debugconsole/article/details/50454884

最新文章

  1. Sublime Text 3 3126 注册码 + 下载地址
  2. day26:面向对象进阶:set、get、del反射和内置
  3. .NET生成静态页面并分页
  4. 【译】仿Taasky的3D翻转菜单动画实现
  5. java 实现从15位~18位的身份证号码转换,校验中国大陆公民身份证、香港居民身份证、澳门身份证和台湾身份证。
  6. RPI学习--webcam_用fswebcam抓取图片
  7. centos6.7 本地yum源配置
  8. 音乐社交APP源码 V1.1
  9. eclipse插入自定义注释(含当前系统时间)
  10. GNU工具链学习笔记
  11. Chrome扩展与用户隐私
  12. 【Spring源码分析】非懒加载的单例Bean初始化过程(下篇)
  13. (NO.00002)iOS游戏精灵战争雏形(七)
  14. springMVC中添加restful 风格
  15. MongoDB官网配置项目整理
  16. CMDB资产管理系统开发【day25】:Django 自定义用户认证
  17. CentOS 6.9搭建CDH 5.12.0集成环境
  18. Windows下运行Linux命令
  19. tableViewCell上的定时器拖动阻塞
  20. BZOJ3779 : 重组病毒

热门文章

  1. SpringCloud微服务Zuul跨域问题
  2. ARTS打卡第四周
  3. .NET Core 图片操作在 Linux/Docker 下的坑
  4. C#编程风格
  5. MySQL之日期时间类型
  6. .Net上传图片的一些问题
  7. Windows服务器上使用phpstudy部署PHP程序
  8. Spark2.2 saveAsTable 函数使用 overWrite 设置 Partition 会造成全覆盖的问题
  9. java的clone()方法
  10. bugku crypto 告诉你一个秘密(ISCCCTF)