I want to create a level sequence with the create asset node, but I need a factory for that. How can I get one without using third party plugins?
Could you explain what you mean with a “factory”? Here is a really great guide on the topic of Level Sequences: Sequencer Overview | Unreal Engine 4.27 Documentation
Hey @PhiiLL!
I am not super well-versed in factories as nothing I’ve ever made needed one, however I know you can create a factory from the “Create Blueprint” menu and there are tons of them you can use!
I want to create a level sequence in the content browser with an action triggered by an editor blueprint utility. For that I can use the “create asset” node, but it needs a factory as an input. If I don’t connect one, the level sequence will be created but crash the engine as soon as I double click it.
(Asset name and package path have been correctly set)
Hey @Mind-Brain,
unfortunately I don’t have these in 4.27
Uh-oh.
Unfortunately this is going to require a bit of C++, as factories are not included as a blueprint option in UE4. The rest of the project should be okay.
Is there a reason you’re trying to avoid plugins? Those plugins are made for those trying to avoid the C++ factor when they’re dealing with blueprint.
Hey @Mind-Brain
I’m trying to avoid third party plugins because it’s a bit of a process to deploy them to all our artists.
But I will try to use an empty level sequence, duplicate and rename it and just go with that.
Thank you for helping me!
I mostly try to stay away from C++. This is a way I do it with Python. Especially with creating assets and datatables its quick and not difficult.
import unreal
asset_lib = unreal.EditorAssetLibrary()
editor_subsystem = unreal.get_editor_subsystem(unreal.EditorUtilitySubsystem)
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
VCam_lib = unreal.VCamBlueprintFunctionLibrary()
sequence_name: str
folder_path: str
def create_level_sequence() -> unreal.LevelSequence:
# Check if Sequence Already exsists
if asset_lib.does_asset_exist(f"{folder_path}{sequence_name}"):
# We found the sequence, Load it
sequence: unreal.LevelSequence = asset_lib.load_asset(asset_path= f"{folder_path}{sequence_name}")
else:
# No Sequence found, so we create a new asset
sequence: unreal.LevelSequence = asset_tools.create_asset(
asset_name= sequence_name,
package_path= folder_path,
asset_class= unreal.LevelSequence,
factory= unreal.LevelSequenceFactoryNew()
)
return sequence
level_sequence = create_level_sequence()
While Python is a perfectly valid way to create assets, you can indeed access asset factories in Blueprints.
In Python, you would instantiate the factory class by calling its constructor function:
import unreal
level_sequence_factory = unreal.LevelSequenceFactoryNew()
However, in Blueprints, there is a Construct Object from Class node, which will do the same thing: