Worst-case scenario: the UEd Goblin wipes the map and burns down your house.

Classes

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 17:22, 28 January 2013 by Eliot (Talk | contribs) (Native implementation modifiers: Added NativeOnly modifier.)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A class is a "blueprint" to create objects, which are also called instances of that class.


Declaration[edit]

Class declarations generally look as follows:

class classname extends parentclass [within outerclass] [modifiers] ;

The class name is a standard identifier, which means it must start with a letter or underscore _, can only contain letters, digits and the underscore character and has a length limit of 63 characters in total. The class name must be unique among all objects (this includes group names and ungrouped resources like textures) within a package. While class names are not required to be unique throughout the engine, it is strongly recommended you do not reuse any existing class names.

The extends clause is mandatory for all classes, except the Object class, which is the root of the class hierarchy and the only class without a parent class. The within clause is optional and available starting with Unreal Engine 2. If specified, instances of this class can only be created within instances of the specified outer class. The class names specified in the extends and within clauses can optionally be qualified with a package name, though this is only necessary if you don't use unique class names.

Modifiers[edit]

The modifier is available in ...
Version Tag Game Engine Version
1 Any Unreal Engine 1 game e.g. UT Unreal Engine 1
2 Any Unreal Engine 2 game e.g. UT2004 Unreal Engine 2
3 Any Unreal Engine 3 game e.g. UT3 Unreal Engine 3
3-x1 UT3 patch 2.0 Unreal Engine 3
3-x2 UDK 2009-12 Unreal Engine 3 - 6000 - present
3-x3 UDK 2010-07 Unreal Engine 3 - 6890 - present
(lesser than i.e. <) A specific version e.g. 3 < 3-x2 would mean it's available in Unreal Engine 3 but not anymore since UDK
(no number) all Unreal Engine generations.
Abstract
No instances can be created of this class.
CacheExemptUT2004
This class should not be exported to UCL files. Only has an effect for classes that are exported by default.
Config(name)
Specifies the configuration file name to use for the config and globalconfig variables in this class. This modifier is inherited. Loading and saving configurable variable values only has an effect if the class or one of its parent classes includes this modifier. In Unreal Engine 1 and 2 the special config names System and User are mapped to the system and user INI files, e.g. UnrealTournament.ini or UT2004.ini and User.ini or whatever is specified via the ini=... or userini=... command line parameters. Similarly the special config names Editor, EditorUserSettings, Engine, Game, Input, MapLists, UI and Vote are mapped to whatever is specified via the engineini=..., editorini=..., etc. command line parameters.
DependsOn(classname)2
Specifies a class that must be parsed before this one. This is only necessary if the class is in the same package and declares a struct or enum type this class wants to use. Note that parent classes and implemented interfaces are always parsed before child classes. Only one class can be specified in the dependson definition, but you can add multiple dependson definitions per class declaration.
Important: The compiler is quite sensitive to bad dependson definitions. If the compiler gets stuck or crashes at the "Analyzing..." stage, make sure your dependson definitons specify valid class names in the same package and do not create circular dependencies.
DependsOn(classname,...)3
Same as the UE2 version, but allows a list of class names.
Deprecated3
Marks the entire class as deprecated. The compiler will issue a warning if your code uses deprecated classes or instances of them. When saving packages, instances of deprecated classes might not be stored in the package file anymore.
Guid(A,B,C,D)2int
The guid the class will use that is saved to disk. This was intended to be used with the Component Object Model, and although the IUnknown interface is implemented natively for all UnrealScript classes, this feature was never actually finished.
Implements(interface)3
This class implements the specified interface. That means the class must implement all functions defined in the interface.
Instanced2
Subobjects of this class or any subclass act as templates. Whenever instances of the class defining the subobject are created, a duplicate of the subobject is created and assigned to the corresponding properties of the new instance.
Localized1
The class has localized members, this is automatic applied in newer engine builds.
ParseConfig2
The config file name for this class can be specified at the command line via the parameter classname=...
PerObjectConfig
Each instance of this class has its own section in configuration files. The non-static SaveConfig() function doesn't propagate the instance values to default values.
PerObjectLocalized3
Each instance of this class can have its own section in localization files. (In earlier engine generations this is always the case.)
SafeReplace1,2
Instances of this class can safely be replaced by some kind of default instance if a specific instance is unavailable. This is only used for Textures, which are replaced by the default texture if the specific texture object does not exist.
Transient, NonTransient3
Whether instances of this class should be marked as "transient". Transient objects can only exist at runtime, but not in package files. This modifier is inherited by subclasses, but it can only be removed from subclasses in Unreal Engine 3 via the nontransient modifier. By default classes are not transient, for obvious reasons.

Editor-related modifiers[edit]

AutoCollapseCategories(name,...)3, DontAutoCollapseCategories(name,...)3
Automatic collapses the specified variable category, categories with no name can be specified by inputting the class's name where the variable is declared in. This is just like CollapseCategories but can specify which category.
AutoExpandCategories(name,...)3
Automatic expands the specified variable category, categories with no name can be specified by inputting the class's name where the variable is declared in.
ClassGroup(name,...)3 - UDK-2010-11
Indicates that this class and its subclasses should be shown in the specified groups in the editor's Actor Classes browser when Group View is enabled.
CollapseCategories2,3, DontCollapseCategories2,3
Whether to hide variable group headers (i.e. collapse variable groups) in property windows. This modifier is inherited and dontcollapsecategories is the default.
DontSortCategories(name,...)3 - UDK
 ???.
EditInlineNew2,3, NotEditInlineNew2,3
Whether instances of this class can be created for editable object variables via a button in the properties window. The editor allows you to select a non-abstract editinlinenew class via a drop-down list.
ForceScriptOrder(true/false)3x3
Forces the property window to display properties from this class in order as declared in the class.
HideCategories(name,...)2,3, ShowCategories(name,...)2,3
Whether to hide the specified property groups from property windows. By default all property groups are displayed. The special group name None contains all properties not belonging to any specific group. This special group is only included in the properties window if it was opened via debug console commands from within the game.
HideDropdown2,3
Hide this class from various drop-down lists in the editor, e.g. for properties of type class. UT2004 also provides the static Actor.ShouldBeHidden() function for actor classes that returns whether the class was declared with the hidedropdown modifier.
NoUserCreate1
Instances of this class can not be created in the editor. Unlike the newer placeable modifier, nousercreate is not inherited.
Placeable2,3, NotPlaceable2,3
Whether instances of this class can be created in the editor. This modifier is inherited to subclasses and the default is notplaceable.

Native implementation modifiers[edit]

DllBind(libraryname)UDK
Enables the DLLBind feature for this class. The class can implement functions that call C functions with the same name in the specified dynamic-link library.
ExportStructs2,3
All structs declared in this non-native class should be exported to native header files. Structs declared in native classes or with the native modifier are also exported without this modifier.
Inherits(classname)3
The native implementation of this class not only inherits from the native implementation of its parent class, but also from the specified C++ class.
Intrinsic1,2
See Native.
Native
This class contains some kind of native code. A class may only be declared as native if it has a native parent class. A C++ declaration for this class is exported to packagenameClasses.h at compile time unless the noexport modifier is specified. The exported C++ declaration includes all variables, structs, enums, delegates and any functions declared with the native or event modifier.
Native(prefix)3
Same as native, except that the native C++ declaration of this class is exported to prefixClasses.h instead.
NativeOnly3
This class cannot contain non-native functions. And other classes cannot access this class's properties. NativeOnly classes cannot extend non-native classes.
Implies: Native
NativeReplication
The conditions for replicating variables contained in this class are specified in native code. The replication block usually only contains an approximate representation of these conditions so UnrealScript programmers can see what is going on. This does not affect conditions for function replication.
NoExport
Prevents exporting headers for this native class. Classes with the noexport modifier use manually created native header files instead.

Native class code[edit]

Like native structs, some classes in Unreal Engine 2 and 3 games may contain native code snippets(cpptext) in UnrealScript. These declarations do not affect UnrealScript directly, but they are exported when auto-generating native headers while compiling UnrealScript classes.