【UE学习记录】试着自己写一个图元(一)

继续学习,参考教程链接:

基本上就是先照着做
中途可能会遇到一些问题,先记录下来,在不影响后续操作的话,等以后再查,先照着教程顺一遍。

一、create plugin
plugin的文档:https://docs.unrealengine.com/en-US/ProductionPipelines/Plugins/index.html
里面有个步骤是在Build.cs文件里引入我们需要的模块。

留个疑问:
这个build.cs是什么东西?
"UE4 is split into many modules. Each module has a .build.cs file that controls how it is built, including options for defining module dependencies, additional libraries, include paths, etc. By default, these modules are compiled into DLLs and loaded by a single executable. You can choose to build a monolithic executable in the BuildConfiguration.cs file."
具体配置看这个:https://zhuanlan.zhihu.com/p/45398694

在代码中出现过#include "xxxx.generated.h"
这个generated.h是个什么东西
"MyClass.generated.h is the include file generated by the UnrealHeaderTool (before UnrealBuildTool compilation) while parsing unreal macros in MyClass.h.
All the UCLASS, USTRUCT, UPROPERTY, UFUNCTION macros produce code in the generated.h and so the Blueprint magic can occur in your project with a minimal effort from your side."
生成路径:ProjectName/Intermediate/Build/PLATFORM/UE4Editor/Inc/ProjectName
还看到有一个说法是generated.h 的include应该在其他include的最后
https://www.unrealengine.com/en-US/blog/unreal-property-system-reflection

在自己写代码的时候,才能发现很多之前看代码没注意到的问题。

GENERATED_USTRUCT_BODY()
GENERATED_UCLASS_BODY()
是什么,为什么新建的struct和class里要写上这个?

最初,先完全按照教程上的代码输进去,希望能够最快速地复现。然后,由于版本更新的原因,原先有些代码需要做些改动。


image.png

方法

  1. 根据编译器给出的错误信息,查看出错的原因。
  2. 如果是版本变动带来的错误,一般都能在网上搜到类似的错误以及解决方案
  3. 对照其他的Plugin源码看怎么写

好不容易将编译错误都修改过来后,使用时却发现会引起crash:

image.png

Assertion failed: Resource [File:D:/Build/++UE4+Licensee/Sync/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11UniformBuffer.cpp] [Line: 267] Invalid resource entry creating uniform buffer, FLocalVertexFactoryUniformShaderParameters.Resources[0], ResourceType 0x6.


看到原教程的评论区,有人遇到了一样的问题,看一个回答是说UE版本的问题,具体怎么改可以去参照CableComponent源码。
所以,下一步是对照着CableComponent,重新梳理一下思路,弄懂这个东西怎么写出来的。


你可能感兴趣的:(【UE学习记录】试着自己写一个图元(一))