| Home Page | Recent Changes | Preferences

DynamicLoadObject

DynamicLoadObject is a native function declared in Object. It loads an object of a specified class. Which object of that class is specified as a string. The string is the name of the thing that you want to load. If that thing does not exist in memory, it will be loaded from the appropriate package file.

Usage

DynamicLoadObject is used almost exclusively to load a resource based on a name supplied as a string. For example, xPlayers.int (UT2003) contains a list of players, each of which has a model, skin, etc. The model name, skin name, and so forth are read in as strings. Then, DynamicLoadObject is used to get Mesh and Material references based on those strings. The reason why they are stored like this is it allows a class to use things that did not exist at compile time, (such as 3rd party models) or classes that exist at compile time, but are not visible from the class compiling time because the class it refers to is compiled after this class.

Syntax

native static final function object DynamicLoadObject( 
 string ObjectName, 
 class ObjectClass, 
 optional bool MayFail );

ObjectName is the name of the object. For instance, "Engine.DefaultTexture" or "xInterface.ExtendedConsole".

ObjectClass is the class of the thing that you are loading. So, for "Engine.DefaultTexture" the ObjectClass would be class'Engine.Material' or class'Engine.Texture'. For "xInterface.ExtendedConsole" it would be class'Class'. (A class is itself a class... called class.) If MayFail is false or is omitted, and the object cannot be loaded, a warning will be printed to the log file. If MayFail is true, no warning will be printed if the object cannot be loaded.

Examples

local class<Actor> aClass;
local Actor A;

aClass = class<Actor>(DynamicLoadObject("MyPackage.MyActorClass", class'Class'));
A = Spawn(aClass);
local class<UWindowList> ListClass;
local UWindowList L;

ListClass = class<UWindowList>(DynamicLoadObject("MyPackage.MyList", class'Class'));
L = New ListClass;
local Texture T;

T = Texture(DynamicLoadObject("MyPackage.MyTexture", class'Texture'));
local Sound S;

S = Sound(DynamicLoadObject("MyPackage.MySound", class'Sound'));

Related Topics


Category To Do – Determine if this page has been properly linked to, if not link up or rework info into relevant pages (i.e., Object)

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