My program doesn't have bugs. It just develops random features.

Difference between revisions of "Cpptext"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
(Created page with 'Starting with Unreal Engine 2 UnrealScript supports '''cpptext'''(prefix for wp:C++<sup>text</sup>) block declarations. The '''cpptext''' is a block declaration where…')
 
m
Line 1: Line 1:
Starting with [[Unreal Engine 2]] [[UnrealScript]] supports '''cpptext'''(prefix for [[wp:C++]]<sup>text</sup>) block declarations. The '''cpptext''' is 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 [[classes|class]] <code>''prefix''Classes.h</code> file when compiled.
+
Starting with [[Unreal Engine 2]] [[UnrealScript]] [[classes]]/[[struct|structs]] support '''cpptext'''(prefix for [[wp:C++]]<sup>text</sup>) block declarations. The '''cpptext''' is 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 [[classes|class]] <code>''prefix''Classes.h</code> file when compiled.
  
Starting with [[Unreal Engine 3]] [[struct|structs]] can also have a '''cpptext''' block but named as '''structcpptext''' instead.
+
'''Note:''' structs use '''cppstruct''' instead and starting with [[Unreal Engine 3]] it was renamed to '''structcpptext'''.
  
 
==Example==
 
==Example==

Revision as of 13:54, 18 May 2010

Starting with Unreal Engine 2 UnrealScript classes/structs support cpptext(prefix for wp:C++text) block declarations. The cpptext is 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 class prefixClasses.h file when compiled.

Note: structs use cppstruct instead and starting with Unreal Engine 3 it was renamed to structcpptext.

Example

Taken from Canvas.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 exports DrawTile into class UCanvas in file EngineClasses.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 to be able to call a function from within UnrealScript.

See also