
上QQ阅读APP看书,第一时间看更新
There's more...
There are a bunch of keywords that we want to discuss here, which modify the way a UCLASS behaves. A UCLASS can be marked as follows:
- Blueprintable: This means that you want to be able to construct a blueprint from the Class Viewer inside the UE4 editor (when you right-click it, Create Blueprint Class... becomes available). Without the Blueprintable keyword, the Create Blueprint Class... option will not be available for your UCLASS, even if you can find it from within the Class Viewer and right-click on it:

- The Create Blueprint Class... option is only available if you specify Blueprintable in your UCLASS macro definition.
- BlueprintType: Using this keyword implies that the UCLASS is usable as a variable from another blueprint. You can create blueprint variables from the Variables group in the left-hand panel of any blueprint's EventGraph.
- NotBlueprintType: Using this keyword specifies that you cannot use this blueprint variable type as a variable in a blueprints diagram. Right-clicking the UCLASS name in the Class Viewer will not show Create Blueprint Class... in its context menu:

You may be unsure whether to declare your C++ class as a UCLASS or not. The general rule of thumb is to use UCLASS unless you have a good reason not to. Unreal Engine 4's code is very well-written and has been tested thoroughly by this point. If you like smart pointers, you may find that UCLASS not only makes for safer code, but also makes the entire code base more coherent and more consistent.