| Home Page | Recent Changes | Preferences

Exec Directive

"#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

Import

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.

Syntax:

#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
NAME
(optional) Name the texture is imported as. Defaults to the file name without extension if omitted.
FILE
Path to the texture being imported. Paths are local to the root of the package directory.
GROUP
(optional) Name of the group the texture is classified under (used in, for example, the UEd Texture browser.)
MIPS
(optional) OFF or ON. Generate MipMaps.
FLAGS
(optional) Numerical value. Assigns the texture rendering style. Valid styles are:
  • 1: 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
PALETTE
(optional) Color palette to use if not default.
LODSET
(optional) Numerical value. Level of detail. Homologous to the LODSet Texture property in UEd. Affects texture clarity as dictated by the user's settings.
  • 0: 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
ALPHA
(UT2003) (optional) Binary value. Defines whether a texture is imported as a Texture with an Alpha Channel
UCLAMPMODE
(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.
VCLAMPMODE
(UT2003) (optional) see UCLAMPMODE.
DXT
(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.

Context:

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)

#exec TEXTURE COMPRESS NAME=Package.TextureName FORMAT=DXT?

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?

Sounds

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

Syntax:

#exec AUDIO IMPORT NAME=NameForSoundToImportAs FILE=PATH\TO\Soundfile.wav GROUP=SomeGroup
NAME
(optional) Name the sound is imported as. Defaults to the file name without extension if omitted.
FILE
Path to the sound file being imported. Paths are local to the root of the package directory.
GROUP
(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.

Packages

Loading Other Packages

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;

defaultproperties
{
    SomeTexture=Texture'MyTextures.SomeCoolTexture_A'
}

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;

defaultproperties
{
    SomeTexture=Texture'MyPackage.SomeCoolTexture_A'
}

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.

Static Meshes

Import

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)

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

ActorX Exported (*.ase files)

#exec NEW STATICMESH NAME=AnotherGrenadeMesh FILE=Models\assaultgrenade2.ase GROUP=TeamWeapons
NAME
Name the static mesh is imported as.
FILE
Path to the static mesh being imported. Paths are local to the root of the package directory.
GROUP
(optional) Name of the group the static mesh is classified under (used in, for example, the UEd static mesh browser.)
PACKAGE
(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

Import

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
MESH
Name that the mesh is imported as.
MODELFILE
Path to the mesh being imported. Paths are local to the root of the package directory.
GROUP
(optional) Name of the group that the mesh is classified under.
LODSTYLE
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

#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

#exec MESH  DEFAULTANIM MESH=Weapon_1st ANIM=WeaponAnim
#exec MESHMAP SETTEXTURE MESHMAP=Weapon_1st NUM=0 TEXTURE=WeaponTex
NUM
Material number the texture is assigned to on the mesh.

Animations

Import

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

#exec ANIM  IMPORT ANIM=WeaponAnim ANIMFILE=models\WeaponAnim.PSA COMPRESS=1 MAXKEYS=999999 IMPORTSEQS=1
ANIM
Name that the animations are imported as.
ANIMFILE
Path to the animations being imported. Paths are local to the root of the package directory.
GROUP
(optional) Name of the group that the mesh is classified under.
COMPRESS
Compresses the animations. 1 is normal, uncompressed, lower numbers are more compressed.
MAXKEYS
not sure
IMPORTSEQS
not sure

Fonts

Importing True Type Fonts

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

Example:

#exec NEW TRUETYPEFONTFACTORY NAME=ZoomStatsFontLarge FONTNAME="OCR A Extended" HEIGHT=24 ANTIALIAS=1 DROPSHADOWX=1 DROPSHADOWY=1 CHARS=".0123456789x"

See TrueTypeFontFactory for more information.

Comments

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?


Refactor Me - This needs Splitting into UT and UT2003 Imports

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

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In