UnrealEngine
共 185 篇文章
[UE4] C++实现Delegate Event实例(例子、example、sample)
相关文章: 如何用蓝图实现Delegate Event: http://aigo.iteye.com/blog/2269663 原文作者:@玄冬Wong 转载请注明出处: http://aigo.iteye.com/blog/2301010 虽然官方doc上说Event的Binding方式跟Multi-Cast用法完全一样,Multi-Cast论坛上也有很多例子,但是实际是不一样。。而且论坛上找不到相关例子。后来看了下runtime/core的源码,Event的binging方式如下(附上完整步骤): 1,先定义自定义Event,此例中我们定义在GameMode中,名字叫 MyInitEve…
2016-05-26 10:33 · UnrealEngine
[UE4]Fog Of War(战争迷雾)教程
[TUTORIAL] Fog Of War https://forums.unrealengine.com/showthread.php?55650-TUTORIAL-Fog-Of-War
2016-05-24 21:08 · UnrealEngine
[UE4]FSocket client客户端如何检测与server服务端断开链接
目前FScoket无法做到感知服务端关闭tcp链接,要做到只能通过两种其他方式: 1,使用BSD socket(建议使用non-blocking mode,因为这样方便终止接收线程); 2,客户端发送心跳包给服务端,如果没有得到回应则认为关闭。 下面方法仅适用于客户端自己关闭连接,如果是服务端关闭是没法感知的 if (Socket->GetConnectionState() != SCS_Connected) { // Socket disconnected } else { if (Socket->HasPendingData(Size)) { Socket->Recv(Data, Max…
2016-05-23 11:32 · UnrealEngine
[UE4]Actor初始化时相关的父类函数
AActor::PreInitalizeComponents - Called before components of the actor are initialized AActor::PostInitalizeComponents - Called after every Component is initialized AActor::PostInitProperties - Called after Blueprint Properties are initialized 原文: https://answers.unrealengine.com/questions/156055/p…
2016-05-14 17:16 · UnrealEngine
[UE4]UMG设置组件自适应居中或靠边
比如你的UI中有些组件需要居中显示,有些需要始终在右上角并且与上边框和右边框保持固定的距离等等,对于这种需要动态适应屏幕分辨率的UI组件,有两种设置方式: 1,直接编辑组件的属性Anchors 2,代码控制 ULoginWidget* LoginUI = NULL; //创建UI的逻辑省略 if (UImage* backImg = Cast<UImage>(LoginUI->GetWidgetFromName("ImgBackground"))) { //获取屏幕大小和中心点 const FVector2D ViewportSize = FVector2D(GEngine->GameVie…
2016-05-11 13:22 · UnrealEngine
[UE4]引擎自身提供的无锁队列等无锁容器(TLockFreePointerList)
常用的接口: TLockFreePointerListFIFO<T> :先进先出; TLockFreePointerListLIFO<T> :后进先出; TLockFreePointerListUnordered<T> :看注释是说这个List内部元素是无序的,但效率比前面两个更高。 注意:如果你的元素是一个指针,比如A* val,那么模版名只需要用A而不要用A*,比如:TLockFreePointerListFIFO<A>。也就是说其内部只能放指针,不像std那样把类的对象作为元素。 想看文档不如直接看源码吧,官方文档的描述跟没写一样。毕竟要靠技术支持收钱,不能讲的太清楚。 源码位置: E…
2016-05-07 16:57 · UnrealEngine
[UE4]如何跨线程访问GameThread中的数据
UE4中如果在自己创建的FRunnable线程中取访问引擎相关的API,比如你想在非GameThread中创建UI,运行时UE4时会给assert错误: Assertion failed: IsInGameThread () [File:D:\BuildFarm\buildmachine_++UE4+Release-4.11\Engine\Source\Runtime\Slate\Public\Framework\Application\SlateApplication.h] [Line: 156] 如何跨线程开访问UE4的API? 看了两个帖子,都说只能搞个queue,自定义线程往queu…
2016-05-07 15:43 · UnrealEngine
[UE4]性能优化工具(Profiler Tool)
Profiler Tool Reference https://docs.unrealengine.com/latest/INT/Engine/Performance/Profiler/index.html 原文: https://www.unrealengine.com/zh-CN/blog/how-to-improve-game-thread-cpu-performance 您游戏中的帧频率是不是太低? 您了解为什么会发生这种现象吗? 这是不是由于您同时生成了太多敌人?还是由于某个特定敌人过于消耗系统资源? 是由于您设置了过多的视觉特效,还是由于您所设计的战斗系统所造成的? 放松一下,不…
2016-05-07 15:28 · UnrealEngine
[UE4]UMG widget构造初始化函数中获取其内部组件
原文作者:@玄冬Wong 目的:在自定义的Widget初始化完毕后,获取其内部的button、combo等UMG组件的C++指针。 这里我们新建了一个C++类,LoginWidget,继承自UserWidget,然后新建了一个Widget蓝图LoginWidgetBP,继承自LoginWidget C++ class。我们想在这个LoginWidgetBP蓝图被实例化之后,获取这个UI蓝图内的各个UI组件。 UserWidget 有两个函数可以做初始化,一个是 bool Initialize(); 一个是 void NativeConstruct(); 第一种方式:Initialize()函…
2016-05-05 23:10 · UnrealEngine
[UE4]C++UI组件Slate教程
官方文档: Slate, Hello https://wiki.unrealengine.com/Slate,_Hello Slate Widget Examples https://docs.unrealengine.com/latest/INT/Programming/Slate/Widgets/ Slate Tutorial https://forums.unrealengine.com/showthread.php?822-Slate-Tutorial
2016-05-05 19:40 · UnrealEngine
[UE4] 设置UMG的ComboBox(String)字体大小
UMG自带ComboBox组件没有提供直接的属性来修改其字体大小,只能自己做一个列表类型的widget然后再塞进ComboBox中,相当于从头定义一个类似combox的widget,当完全由你重新定义的时候,可以修改的不只是字体大小了。下面教程以修改字体大小为例: 图文教程 How do I set the font size of the UMG ComboBox (String)? https://answers.unrealengine.com/questions/126758/how-do-i-set-the-font-size-of-the-umg-combobox-str.htm…
2016-05-04 08:18 · UnrealEngine
[UE4]性能优化之:如何减少drawcall
Using Instanced Meshes doesn't reduce draw calls 原文: https://answers.unrealengine.com/questions/127435/using-instanced-meshes-doesnt-reduce-draw-calls.html epic工程师的回答: Instanced meshes will reduce the draw call overhead on the CPU but will not reduce the GPU cost. In fact the GPU time can increase …
2016-05-03 20:02 · UnrealEngine
[UE4]如何查看drawcall实时统计
命令行(按下波浪键)输入: stat SceneRendering 更多stat命令说明: Stat Commands https://docs.unrealengine.com/latest/INT/Engine/Performance/StatCommands/
2016-05-03 19:59 · UnrealEngine
[UE4]protoc生成的代码编译问题:error LNK2019: unresolved external symbol "public: __cdec
ue4工程编译时,如果只是将protobuf.lib链接进来,不加入protoc生成的代码,那么编译时没有问题的,但是如果加进来了,那么就跪了: error LNK2019: unresolved external symbol "public: __cdecl 。。。" 之前这个问题没想明白,以为可以通过设置工程来解决这个错误,后来想了想,protoc生成的代码都是标准c++代码,其头文件定义class的位置没有加入UE4工程的宏,比如:MyProject_API;另外cpp文件有没有包含工程的头文件,比如:#include "MyProject.h"。 如何解决呢,如果直接修改这些生成的…
2016-05-03 12:26 · UnrealEngine · protobuf
[UE4]warning CS0612: 'UnrealBuildTool.RulesCompiler.GetModuleFilename(string)' i
如果在build.cs构建配置中添加如下代码: RulesCompiler.GetModuleFilename() 则编译时会出现警告或错误(preview版本中貌似不允许你使用直接提示error,正式版允许你编译通过但是会提示此API已经废除掉了): warning CS0612: 'UnrealBuildTool.RulesCompiler.GetModuleFilename(string)' is obsolete 解决办法: 演示例子是获取第三方库的目录的(假设../../ThirdParty/是我们工程存放第三方库的位置) using System.IO; using Unreal…
2016-04-25 12:24 · UnrealEngine
[UE4]FMath中的常用数学公式函数
FMath::CeilLogTwo(uint32 value) 含义:返回大于等于value的以2为底数的最大N次幂的指数N(是指数,不是幂)。 例子:value=15,返回值为4,因为16是大于等于15的2的N次幂当中最小的次幂,其对应的指数为4。 FMath::FloorLog2(uint32 value) 含义:与CeilLogTwo函数相反,返回小于等于value的以2为底数的最小N次幂的指数N。 例子:value=15,返回值为3,因为8是小于等于15的2的N次幂当中最大的次幂,其对应的指数为3。 FMath::IsPowerOfTwo<T>(T value) 含义:判断value…
2016-04-20 07:38 · UnrealEngine · Math
[UE4]boost lib连接错误:LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL'
UE4工程的debug模式链接boost的时候出现错误: UE4 boost error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in 以下是UE4源码的注释,意思是说UE4编译器在编译debug版本的时候仍然会链接release版本的第三方库,因为UE4的编译器不支持在调试debug版本的第三方库。 // By default we use the Release C++ Runtime (CRT), even when compiling Debug…
2016-04-20 07:37 · UnrealEngine
[UE4]退出游戏的API(C++)
官方文档: UKismetSystemLibrary::QuitGame https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Kismet/UKismetSystemLibrary/QuitGame/index.html 示例: #include "KismetSystemLibrary.h" void ASomeActor::SomeActorFunction() { UKismetSystemLibrary::QuitGame(this, nullptr, EQuitPreference::Quit); }
2016-04-18 00:32 · UnrealEngine
[UE4]已支持的C++11特性
官方文档: C++ 11 and Modern Language Syntax https://docs-origin.unrealengine.com/latest/INT/Programming/Development/CodingStandard/index.html#c++11andmodernlanguagesyntax
2016-04-17 17:22 · UnrealEngine
[UE4]服务端构建后启动错误:GlobalShaderCache-PCD3D_SM5.bin is missing
原文作者:@玄冬Wong 构建独立服务端后启动报错: [2016.04.15-11.22.50:980][ 0]LogMaterial:Error: The global shader cache file 'F:/EpicGames/UnrealEngine-4.11.0-release/Engine/GlobalShaderCache-PCD3D_SM5.bin' is missing. Your application is built to load COOKED content. No COOKED content was found; This usually means you…
2016-04-15 19:28 · UnrealEngine