StaticConstructObject

The StaticConstructObject function attempts to construct a UE4 object of some type.

This function mimics the function StaticConstructObject_Internal.

Parameters (overload #1)

#TypeInformation
1UClassThe class of the object to construct
2UObjectThe outer to construct the object inside
3FNameOptional
4integerOptional, 64 bit integer
5integerOptional, 64 bit integer
6boolOptional
7boolOptional
8UObjectOptional
9integerOptional, 64 bit integer
10integerOptional, 64 bit integer
11integerOptional, 64 bit integer

Parameters (overload #2)

#TypeInformation
1UClassThe class of the object to construct
2UObjectThe outer to construct the object inside
3integerOptional, 64 bit integer representation (ComparisonIndex & Number) of an FName
4integerOptional, 64 bit integer
5integerOptional, 64 bit integer
6boolOptional
7boolOptional
8UObjectOptional
9integerOptional, 64 bit integer
10integerOptional, 64 bit integer
11integerOptional, 64 bit integer

Return Value

#TypeInformation
1UObjectObject is only valid if an object was successfully constructed

Example

This example constructs a UConsole object.

local Engine = FindFirstOf("Engine")
local ConsoleClass = Engine.ConsoleClass
local GameViewport = Engine.GameViewport

if not ConsoleClass:IsValid() or not GameViewport:IsValid() then
    print("Was unable to construct UConsole because the console class didn't exist\n")
else
    local CreatedConsole = StaticConstructObject(ConsoleClass, GameViewport, 0, 0, 0, nil, false, false, nil)

    if CreatedConsole:IsValid() then
        print(string.format("CreatedConsole: %s\n", CreatedConsole:GetFullName()))
    else
        print("Was unable to construct UConsole\n")
    end
end