Http://wiki.beyondunreal.com/Cpptext
The Section Cpptext {} was found in UScript, which is amazing. I thought it was similar to querying Wiki. This is a pre-declaration of CPP in the script,
Reference:
"
Unreal Script can be embedded in assembly, but can only be used in cpptext as part of the C ++ generation function.
If it is elsewhere, it is not yet supported, because it does not make sense to support it, because even if compilation can be embedded, you can only embed virtual commands of UnrealScript virtual machines, but these commands are very dangerous.
Moreover, commands embedded with virtual machines cannot bring efficiency advantages.
"
CpptextFrom Unreal Wiki, The Unreal Engine Documentation SiteJump to: navigation, search
Starting with Unreal Engine 2 UnrealScript classes/structs supportCpptext(Prefix for C ++ text) block declarations.CpptextIs a block declaration where programmers can implement C ++ functions it also can only be declared in native classes, any text within this block will then be exported to the corresponding native classprefixClasses.h
File when compiled.
Note:Structs useCppstructInstead and starting with Unreal Engine 3 it was renamedStructcpptext.
Example
Taken fromCanvas.uc
.
cpptext{ //... void DrawTile(UTexture* Tex, FLOAT X, FLOAT Y, FLOAT XL, FLOAT YL, FLOAT U, FLOAT V, FLOAT UL, FLOAT VL, const FLinearColor& Color); //...}
This exportsDrawTile
Into classUCanvas
In fileEngineClasses.h
E.g.
class UCanvas : public UObject{ //... void DrawTile(UTexture* Tex, FLOAT X, FLOAT Y, FLOAT XL, FLOAT YL, FLOAT U, FLOAT V, FLOAT UL, FLOAT VL, const FLinearColor& Color); //...};
Why use cpptext over native functions
Even though you can just make a native UnrealScript function that will also get exported the same way but then translated to C ++, it doesn't support all formats thus in that case the native coder can implement functions that cannot be declared in UnrealScript but also because the native coder might not want you can be able to call a function from within UnrealScript.
See also
- Native Coding
- Native-only classes