May-08-2019, 10:44 PM
Hey there. So I'm fairly a beginner when it comes to python and I'm trying to reverse engineer this script to learn something
more advanced but I can't really get thru it, mainly the ((createGenericAsset Function)) bit. I can identify what's being used - function, tuple, if statement, but I can't break it apart to really understand what it's doing. If anyone could help and possibly give tips on how to break it apart and run it piece by piece to help figure it out would be amazing. I'll settle for some good documentation as well, typical if statement and tuple documentation doesn't get me far enough. Alas,...
more advanced but I can't really get thru it, mainly the ((createGenericAsset Function)) bit. I can identify what's being used - function, tuple, if statement, but I can't break it apart to really understand what it's doing. If anyone could help and possibly give tips on how to break it apart and run it piece by piece to help figure it out would be amazing. I'll settle for some good documentation as well, typical if statement and tuple documentation doesn't get me far enough. Alas,...
def createGenericAsset(asset_path='', unique_name=True, asset_class=None, asset_factory=None): if unique_name: asset_path, asset_name = unreal.AssetToolsHelpers.get_asset_tools().create_unique_asset_name(base_package_name=asset_path, suffix='') if not unreal.EditorAssetLibrary.does_asset_exist(asset_path=asset_path): path = asset_path.rsplit('/', 1)[0] name = asset_path.rsplit('/', 1)[1] return unreal.AssetToolsHelpers.get_asset_tools().create_asset(asset_name=name, package_path=path, asset_class=asset_class, factory=asset_factory) return unreal.load_asset(asset_path) def createGenericAsset_EXAMPLE(): base_path = '/Game/user/tom/' generic_assets = [ [base_path + 'sequence', unreal.LevelSequence, unreal.LevelSequenceFactoryNew()], [base_path + 'material', unreal.Material, unreal.MaterialFactoryNew()], [base_path + 'world', unreal.World, unreal.WorldFactory()], [base_path + 'particle_system', unreal.ParticleSystem, unreal.ParticleSystemFactoryNew()], [base_path + 'paper_flipbook', unreal.PaperFlipbook, unreal.PaperFlipbookFactory()], [base_path + 'data_table', unreal.DataTable, unreal.DataTableFactory()], # Will not work ] for asset in generic_assets: print createGenericAsset(asset[0], True, asset[1], asset[2])#FootNote: Original Script written by Alex Quevillon posted on GitHub