![]() ![]() If you’re interested about this part, you can find some more details about reflection on this excellent post by Michael Noland, and on the official doc page for the unreal UObjects. That one in particular allows our UMyObject objects to interact with blueprints, but you can check the source for all the optional arguments you can provide for UCLASS. You can provide some optional arguments to some of these annotations, like how we did UCLASS( BlueprintType ). You will likely never need to interact with the "*.generated.h" files though, and that’s good, because there’s some pretty crazy auto-generated code in there. Part of that generated code goes in that "" file, and part of that code is injected in the location of that GENERATED_BODY() macro just before we compile. Instead, these macros work more as annotations: UHT will parse this code, see those anotations (like UCLASS()), and know that it needs to generate some code about that class and place it somewhere (and obviously remove the annotations afterwards). Note that these macros just expand to more macros, and won’t help us understand what’s going on (although you can peek at the UCLASS macro if you want). ![]() We also added a couple of includes, and a couple of macros, which are required to get Unreal Header Tool (UHT) to automatically generate some code for us when we compile. We also had to rename our class to UMyObject, as that is the naming convention for classes that derive from UObject. In order to see MyValue and MyValueArray in the editor, interact with our class via blueprints or even create a blueprint class that derives MyObject, we need some changes: #include "UObject/ObjectMacros.h"Ī few things happened here: We derived from UObject, which is the base class for objects managed by Unreal and is required to get our class garbage collected, replicated over the network, serialized, and more. I’m using a TArray data member here, but that’s just an analogue for std::vector, so there’s nothing special there. Let’s start off with a simple, pure C++ class. Hopefully this post works as sort of a crash course on the base classes of the engine. Let’s get into it then! The purpose of this post is to explain how UObject, UClass, UBlueprint, UBlueprintGeneratedClass and other concepts like the Class Default Object all interact. If you don’t have access to it yet, you can get it for free in just a couple of seconds by following this guide. I will sometimes link straight to the UE source on Github at some points. This post is about UE 4.26 in particular, but most of these details probably haven’t changed much since UE 3. ![]() ![]() It also sucks that everyone has to rediscover the same insights over and over, so hopefully this can provide a net saving of man hours to the world. It seems like the community just assumes everyone is forced to dig through the code, and while there’s nothing fundamentally wrong with reading code, it does get in the way a bit when all you want is an overview. This is mostly to get the ball rolling as far as this blog is concerned (as working with Unreal is a large part of my day job and should be the easiest to write about), but also because UE’s documentation is not the best, and there’s a surprising shortage of posts like this out there. This is going to be the first of a few of blog posts detailing some stuff I’ve learned doing deep dives in the Unreal Engine source. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |