I love the smell of UnrealEd crashing in the morning. – tarquin

Legacy:Exec Directive

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

"#exec" directives in UnrealScript class syntax execute console commands at compile time. This is useful for keeping content closely coupled with the code that uses it (textures/sounds), or for referenced separate content packages for organizational purposes.

Every "#exec" directive can be executed in UnrealEd's console bar (without the "#exec" part). Currently in the newer engine builds, they are the only method of importing vertex meshes (think .3ds).

Look for lines in Editor.log that start with "Cmd:" to find out about more possibly interesing exec directives.

See UnrealEd Console for more information on this fun stuff!

See Exec Directive (UT) for UT Import commands.



Textures can be imported upon compilation of a class or series of classes into a .u package. This is done using the #exec preprocessing directive.


#exec TEXTURE IMPORT NAME=NameForTextureToImportAs FILE=PATH\TO\SomeTexture.pcx GROUP=SomeGroup MIPS=OFF FLAGS=2 PALETTE=SomeTexPalette LODSET=2
// note no terminating ";". Presumably must be all on one line, too
(optional) Name the texture is imported as. Defaults to the file name without extension if omitted.
Path to the texture being imported. Paths are local to the root of the package directory.
(optional) Name of the group the texture is classified under (used in, for example, the UEd Texture browser.)
(optional) OFF or ON. Generate MipMaps.
(optional) Numerical value. Assigns the texture rendering style. Valid styles are:
  • Normal
  • 2: 2-sided – isn't that masked? →WormboKirin Yes Wormbo it is → SabbathCat: In most UT code FLAGS=2 is commented as just "two sided".
  • 3: Translucent 2-sided
  • 4: Masked 2-sided
  • 5: Modulated 2-sided
(optional) Color palette to use if not default.
(optional) Numerical value. Level of detail. Homologous to the LODSet Texture property in UEd. Affects texture clarity as dictated by the user's settings.
  • no detail settings applied.
  • 1: LODSET_World – affected by user's World Texture Detail setting.
  • 2: LODSET_Skin (or LODSET_PlayerSkin for (UT2003) ) – affected by user's Skin Detail setting.
  • 3: (UT2003) LODSET_WeaponSkin – used for weapon textures
  • 4: (UT2003) LODSET_Terrain – used for Terrain textures
  • 5: (UT2003) LODSET_Interface – used for menu items like HUD and Player Portraits
  • 6: (UT2003) LODSET_RenderMap – used for shaders
  • 7: (UT2003) LODSET_LightMap – used for light maps
  • 8: (SWAT4) LODSET_NormalMap
(UT2003) (optional) Binary value. Defines whether a texture is imported as a Texture with an Alpha Channel
(UT2003) (optional) can be CLAMP or WRAP, WRAP is default, so you don't have to add it then. I'm not totaly sure what is does, but it's needed for projector textures, and for team symbols.
(UT2003) (optional) see UCLAMPMODE.
(UT2003) (optional) One of: 1/3/5. DXT format to use when compressing the imported texture.

Note that it's possible but usually not practical to include a PACKAGE=... parameter. There may also be other parameters, but the ones listed above should be all you ever need.


class SomeClass extends SomeActor;
#exec TEXTURE IMPORT NAME=SomeTex1 FILE=Textures\SomeTexture.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=SomeTex2 FILE=Textures\AnotherTexture.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=SomeTex3 FILE=Textures\StillAnotherTexture.pcx GROUP=Skins FLAGS=2

Imported textures are addressed as PackageName.Texturename, and available via UnrealEd after PackageName is loaded in the Actor browser.

See also Texture Import And Export

Compressing (UT2003)[edit]


DJPaul: To compress a texture to a format. Replace "DXT?" with a compresssion type: i.e. DXT1, DXT3, or DXT5.

Kirin: Default is RGBA8 for non-DDS files (eg. TGA) and DXT? for DDS files depending on what was imported. You can use the DXT Tools for Photoshop from http://developer.nvidia.com/view.asp?IO=ps_texture_compression_plugin to export a DDS texture from Photoshop. non-nVidia users: Don't it worry! It'll work if you don't have an nvidia card. I have a Radeon 9700 and the preview function hasn't bailed on me yet. ;)

Kirin: WOW! That's a lot added in UT2003. Just added a bunch of discovered LODSET variables

smattbac Package Reference. It seems that if you only reference to an object in a package in the defaultproperties, you don't have to load the file (is this true for all engine builds?), but it might be good practice to load it anyway.

Uncommon: I have had zero luck getting the compress directive to work. None of the UT2003 classes use it; instead they have DXT=1-5 at the end of the TEXTURE IMPORT line. But that didn't work for me either (sure would help if there was an error message!). I ended up doing the compressing in UnrealEd, exporting the .dds file, and importing that instead.

Faithful: This TEXTURE COMPRESS directive appears to be a UnrealEd-only command. Note that ucc make's #exec will not give errors for commands it does not recognize, but simply will do nothing (resulting in everyone's complete failure to get this exec directive to work). Perhaps confusions like this could be solved if all new Editor.log-found directives were first added to UnrealEd Console and later (if found to work with the MakeCommandlet) could be copied here or to a "common exec directive" page of sorts. Also I wasn't able to get TEXTURE IMPORT's DXT= property to give me any problems. I'm using UCC.exe from UT2004 patch 3204.

BlackHawk: Isn't this TEXTURE COMPRESS directive supposed to be called AFTER you do a TEXTURE IMPORT, in which you put it in a package and give it a name?


To import sound files into your code package, a syntax similar to texture import is used.


#exec AUDIO IMPORT NAME=NameForSoundToImportAs FILE=PATH\TO\Soundfile.wav GROUP=SomeGroup
(optional) Name the sound is imported as. Defaults to the file name without extension if omitted.
Path to the sound file being imported. Paths are local to the root of the package directory.
(optional) Name of the group the sound is classified under (used in, for example, the UEd Sound browser.)

Note that it's possible but usually not practical to include a PACKAGE=... parameter.

See Importing Sounds for details about supported sound file formats.


Loading Other Packages[edit]

You can use the OBJ LOAD parameters to load a specific file at compile time, so that you can reference objects in that package at compile time. For example, say you want to store a bunch of textures in a seperate .utx so that you don't necessarily have to re-compile the package everytime you want to update/change/add/remove textures, you could do something like:

#exec OBJ LOAD FILE="..\Textures\MyTextures.utx"
var Texture SomeTexture;

You can use OBJ LOAD to load any sort of Unreal package, be it for textures, sounds, animations, or even other script packages. Useful sometimes for bypassing annoying dependency issues as well (although you should probably just design your code not to have these in the first place).

PACKAGE specifies the package which the referenced FILE is compiled into. Setting it equal to the package in which the calling class resides will compile the loaded package into the compiled package. For example, with a texture package called MyTextures.utx and a script MyScript.uc in package MyPackage:

#exec OBJ LOAD FILE="..\Textures\MyTextures.utx" PACKAGE=MyPackage
var Texture SomeTexture;

SomeCoolTexture can then be referenced through MyPackage instead of MyTextures, eliminating the need for a separate texture package when MyPackage is distributed.

Oh yes, here's a little something I learned the hard way...if you want to EXEC OBJ LOAD files, make certain they have different names (i.e., it doesn't like having MyModWeapons.utx and MyModWeapons.uax). Simple work-around is to just name them like MyModWeaponsSkins.utx and MyModWeaponsSounds.uax. Sigh. Maybe I'm just an idiot, but it took me 10 minutes to figure that out. Hopefully this will save someone else that trouble.

computergod666: I'm trying to create a weapon type using the ASMD mesh from Unreal (for UT). I have all the code OK. Will this allow me to import the meshes and textures from UnrealShare or wherever the ASMD data is stored? For example:

#exec OBJ LOAD FILE="../System/UnrealShare.u"
//code to load up the meshes, animations, and textures goes here.

Static Meshes[edit]


You can import static meshes to be compiled in your .u file. You can import Lightwave (.lwo) and the .ase files exported from the ActorX Utility.

Lightwave (*.lwo files)[edit]

#exec STATICMESH IMPORT NAME=GrenadeMesh FILE=Models\assaultgrenade.lwo GROUP=EnemyWeapons

ActorX Exported (*.ase files)[edit]

#exec NEW STATICMESH NAME=AnotherGrenadeMesh FILE=Models\assaultgrenade2.ase GROUP=TeamWeapons
Name the static mesh is imported as.
Path to the static mesh being imported. Paths are local to the root of the package directory.
(optional) Name of the group the static mesh is classified under (used in, for example, the UEd static mesh browser.)
(optional) I'm not sure about this one. It is the name of the package you want to import the static mesh into. Not much use for this in compiling a .u file. However, you may be able to use it to create a batch compiler to compile and save out several packages at once? Like I said I'm not sure.

Daid303: There seems to be another parameter called "COLLISION" it's used alot in the resource UC files in UT2003, but I have no idea what it does.

Oh, wait if you say "COLLISION=0" then all the Materials have EnableCollision to false. Any idea what that does?

Skeletal Meshes[edit]


You can import .PSK files obtained from the ActorX utility, that are placed in the /models folder of your package directory.

#exec MESH  MODELIMPORT MESH=Weapon_1st MODELFILE=models\WeaponModel.PSK LODSTYLE=10
Name that the mesh is imported as.
Path to the mesh being imported. Paths are local to the root of the package directory.
(optional) Name of the group that the mesh is classified under.
not sure - I use 10 for weapons fine.

See also http://unreal.epicgames.com/skeletal/UtSkelAnim.htm for more detailed information.

Position, Rotation and Scale[edit]

#exec MESH  ORIGIN MESH=Weapon_1st X=0 Y=0 Z=0 YAW=0 PITCH=0 ROLL=0
#exec MESHMAP   SCALE MESHMAP=Weapon_1st X=1.0 Y=1.0 Z=1.0

In this case the rotation unit is a byte: a full circle is 255.

Assign Animations and Textures[edit]

#exec MESH  DEFAULTANIM MESH=Weapon_1st ANIM=WeaponAnim
Material number the texture is assigned to on the mesh.



You can import .PSA files obtained from the ActorX utility, that are placed in the /models folder of your package directory.

Name that the animations are imported as.
Path to the animations being imported. Paths are local to the root of the package directory.
(optional) Name of the group that the mesh is classified under.
Compresses the animations. 1 is normal, uncompressed, lower numbers are more compressed.
not sure
not sure


Importing True Type Fonts[edit]

Importing fonts involves using the NEW command with a factory class, the Aa TrueTypeFontFactory.



See TrueTypeFontFactory for more information.


BlackHawk: Does anyone know if there is a way to construct shaders in an automatic way?

For example: you create a diffuse, specular, and opacity texture that have you want combined in a shader. Is there another way to do this, besides doing it by hand?

Skydev: This page is missing information about importing VertMeshes from .3d files.

Some information on that can be found here and here

Category:Legacy Refactor Me - This needs Splitting into UT and UT2003 Imports

Category:Legacy To Do – What is UT2003 and which is UT? Remove UT-only stuff from this page