Dynamic arrays
Dynamic arrays are a special composite type in UnrealScript that contains a variable number of elements in a well-defined order. These elements all have the same type, called the "inner type" of the array.
UnrealScript's dynamic arrays are a true dynamic array implementation, i.e. unlike Java's dynamically-allocated fixed-size arrays they can be resized at runtime. The type declaration syntax was available (almost) from the start, but Unreal Engine 1 never provided any way to actually access or modify them at the UnrealScript level. In other words, dynamic arrays are fully usable in UnrealScript only in Unreal Engine 2 and later.
Unlike any other data type in UnrealScript, dynamic arrays have absolutely no support for replication. Attempting to replicate a dynamic array variable will have no effect on the remote instance of that variable. Attempting to use a dynamic array as parameter of a replicated function will result in the parameter being empty when the function is executed on the remote side.
Declaration syntax
Dynamic arrays are declared as part of the type:
array< type >
The inner type of a dynamic array can be a class limiter or the name of any other non-array type, including delegate types. Note that Unreal Engine 2 does not support dynamic arrays of type bool and the compiler will complain accordingly. Dynamic arrays of bool values are possible in Unreal Engine 3, though.
A dynamic array type can be used in all places that allow a type definition. The following example code defines a class-global dynamic array of bytes and a function that uses dynamic arrays as return type and as the type of a parameter and a local variable: <uscript> var array<byte> ByteArray;
function array<int> RoundAll(array<float> Values) {
local array<int> Result;
//...
return Result;
} </uscript> The only exception are type declarations of variables, struct members and function parameters that are declared as static arrays. In this case, the dynamic array declaration is ignored.
Usage in code
This short section needs to be expanded. |
Usage in defaultproperties block
This short section needs to be expanded. |
Usage in UnrealEd
This short section needs to be expanded. |
Declarations | Preprocessor • Classes • Interfaces • Cpptext • Constants • Enums • Structs • Variables (Metadata) • Replication block • Operators • Delegates • Functions • States • Defaultproperties (Subobjects) |
---|---|
Types | bool • byte • float • int • name • string • Object • Class • Enums • Structs (Vector ⋅ Rotator ⋅ Quat ⋅ Color) • Static arrays • Dynamic arrays • Delegates • Typecasting |
Literals | Boolean • Float • Integer • Names • Objects (None ⋅ Self) • Vectors • Rotators • Strings |
Flow | GoTo • If • Assert • Return • Stop • Switch • While • Do...Until • For • ForEach • Break • Continue |
Specifiers | Super • Global • Static • Default • Const |
UnrealScript | Syntax • .UC • .UCI • .UPKG • Comments • #directives • Native |