RapyutaSimulationPlugins
Static Public Member Functions | List of all members
URRAssetUtils Class Reference

Asset utils. More...

#include <RRAssetUtils.h>

Inheritance diagram for URRAssetUtils:
Inheritance graph
[legend]
Collaboration diagram for URRAssetUtils:
Collaboration graph
[legend]

Static Public Member Functions

static IAssetRegistry & GetAssetRegistry ()
 
static bool GetAssetFilePathOnDisk (const FString &InAssetPath, FString &OutAssetFilePath)
 Get full asset file path on disk of an UE asset. More...
 
static bool IsAssetPackageValid (const FAssetData &InAssetData, bool bIsLogged=false)
 
static bool IsAssetDataListValid (const TArray< FAssetData > &InAssetDataList, bool bLoadedCheck, bool bIsLogged=false)
 
template<typename T >
static void LoadAssetDataList (const FString &InAssetsPath, TArray< FAssetData > &OutAssetDataList, bool bHasBPAsset=false, bool bIsFullLoad=false)
 Load asset with UObjectLibrary. More...
 
template<typename T >
static FORCEINLINE T * LoadObjFromAssetPath (UObject *Outer, const FString &InAssetPath)
 This must not be invoked at Sim initialization since it would flush Async loaders away! More...
 
template<typename T >
static FORCEINLINE T * FetchObjectFromAsset (const TCHAR *InAssetPath)
 Fetch UObject from asset, called in Constructor only. More...
 
template<typename T >
static FORCEINLINE TSubclassOf< T > FetchClassFromAsset (const TCHAR *InClassAssetPath)
 Fetch UClass from asset, called in Constructor only. More...
 
static bool DoesAssetExist (const FString &InAssetPath, bool bOnDiskAssetOnly=false)
 Check whether an asset has been created at a path. More...
 
static UPackage * CreatePackageForSavingToAsset (const TCHAR *InPackageName, const EPackageFlags InPackageFlags=(PKG_NewlyCreated|PKG_RuntimeGenerated))
 Create a package meant to be saved to asset file on disk. More...
 
static UObject * SaveObjectToAssetInModule (UObject *InObject, const ERRResourceDataType InAssetDataType, const FString &InAssetUniqueName, const TCHAR *InModuleName, bool bSaveDuplicatedObject=false, bool bInStripEditorOnlyContent=false, bool bInAsyncSave=true, bool bInAlwaysOverwrite=false)
 Save object in memory to asset file on disk stored by a module. More...
 
static UObject * SaveObjectToAsset (UObject *InObject, const FString &InAssetPath, bool bSaveDuplicatedObject=false, bool bInStripEditorOnlyContent=false, bool bInAsyncSave=true, bool bInAlwaysOverwrite=false)
 Save object in memory to asset file on disk. More...
 
static bool SavePackageToAsset (UPackage *InPackage, UObject *InObject, bool bInAsyncSave=true, bool bInAlwaysOverwrite=false)
 Save package to asset file on disk. More...
 
static UClass * FindBlueprintClass (const FString &InBlueprintClassName)
 Find generated UClass from blueprint class name. More...
 
static UClass * FindClassFromPathName (const FString &InClassPathName)
 
static UClass * CreateBlueprintClass (UClass *InParentClass, const FString &InBlueprintClassName, const TFunction< void(UObject *InCDO)> &InCDOFunc=nullptr, const bool bInSaveBP=false, const FString &InBPBasePath=TEXT(""))
 Create a child blueprint class from parent UClass. More...
 
static UBlueprint * CreateBlueprintFromActor (AActor *InActor, const FString &InBlueprintClassName, const bool bInSaveBP, const TFunction< void(UObject *InCDO)> &InCDOFunc=nullptr)
 Create a blueprint from an AActor. More...
 

Detailed Description

Asset utils.

See also
AsyncLoading
AssetRegistry

UCLASS()

Member Function Documentation

◆ CreateBlueprintClass()

static UClass* URRAssetUtils::CreateBlueprintClass ( UClass *  InParentClass,
const FString &  InBlueprintClassName,
const TFunction< void(UObject *InCDO)> &  InCDOFunc = nullptr,
const bool  bInSaveBP = false,
const FString &  InBPBasePath = TEXT("") 
)
static

Create a child blueprint class from parent UClass.

Parameters
InParentClass
InBlueprintClassName
InCDOFuncFunction to get Class Default Object(CDO) as arg.
bInSaveBPWhether or not saving the output BP to disk
InBPBasePathBase UE path for saving BP
Returns
UClass*
See also
[FKismetEditorUtilities::CreateBlueprintFromClass()]
Objects

◆ CreateBlueprintFromActor()

static UBlueprint* URRAssetUtils::CreateBlueprintFromActor ( AActor *  InActor,
const FString &  InBlueprintClassName,
const bool  bInSaveBP,
const TFunction< void(UObject *InCDO)> &  InCDOFunc = nullptr 
)
static

Create a blueprint from an AActor.

Ref: [FKismetEditorUtilities::CreateBlueprintFromActor()]

Parameters
InActor
InBlueprintClassName
bInSaveBPWhether or not saving the output BP to disk
InCDOFuncCallback to init CDO
Returns
UBlueprint*

◆ CreatePackageForSavingToAsset()

static UPackage* URRAssetUtils::CreatePackageForSavingToAsset ( const TCHAR *  InPackageName,
const EPackageFlags  InPackageFlags = (PKG_NewlyCreated|PKG_RuntimeGenerated) 
)
static

Create a package meant to be saved to asset file on disk.

Parameters
InPackageName
InPackageFlags
Returns
UPackage*

◆ DoesAssetExist()

static bool URRAssetUtils::DoesAssetExist ( const FString &  InAssetPath,
bool  bOnDiskAssetOnly = false 
)
inlinestatic

Check whether an asset has been created at a path.

Parameters
InAssetPathFull UE asset path (eg: /Game/Contents/DynamicContents/SK_Obj)
bOnDiskAssetOnly
Returns
bool

◆ FetchClassFromAsset()

template<typename T >
static FORCEINLINE TSubclassOf<T> URRAssetUtils::FetchClassFromAsset ( const TCHAR *  InClassAssetPath)
inlinestatic

Fetch UClass from asset, called in Constructor only.

Template Parameters
T
Parameters
InClassAssetPath,whichrequires trailing "_C"
Returns
TSubclassOf<T>

◆ FetchObjectFromAsset()

template<typename T >
static FORCEINLINE T* URRAssetUtils::FetchObjectFromAsset ( const TCHAR *  InAssetPath)
inlinestatic

Fetch UObject from asset, called in Constructor only.

Template Parameters
T
Parameters
InAssetPath
Returns
T*

◆ FindBlueprintClass()

static UClass* URRAssetUtils::FindBlueprintClass ( const FString &  InBlueprintClassName)
static

Find generated UClass from blueprint class name.

Parameters
InBlueprintClassNameEither name or object path to blueprint class
Returns
UClass*
Note
Refs: EditorUtilitySubsystem
See also
https://maladius.com/posts/asset_manager_1
http://kantandev.com/articles/finding-all-classes-blueprints-with-a-given-base

◆ FindClassFromPathName()

static UClass* URRAssetUtils::FindClassFromPathName ( const FString &  InClassPathName)
inlinestatic

◆ GetAssetFilePathOnDisk()

static bool URRAssetUtils::GetAssetFilePathOnDisk ( const FString &  InAssetPath,
FString &  OutAssetFilePath 
)
inlinestatic

Get full asset file path on disk of an UE asset.

Parameters
InAssetPathUE asset path
OutAssetFilePathOutput asset file path on disk (local path)
Returns
true if convertible

◆ GetAssetRegistry()

static IAssetRegistry& URRAssetUtils::GetAssetRegistry ( )
inlinestatic

◆ IsAssetDataListValid()

static bool URRAssetUtils::IsAssetDataListValid ( const TArray< FAssetData > &  InAssetDataList,
bool  bLoadedCheck,
bool  bIsLogged = false 
)
inlinestatic

◆ IsAssetPackageValid()

static bool URRAssetUtils::IsAssetPackageValid ( const FAssetData &  InAssetData,
bool  bIsLogged = false 
)
inlinestatic

◆ LoadAssetDataList()

template<typename T >
static void URRAssetUtils::LoadAssetDataList ( const FString &  InAssetsPath,
TArray< FAssetData > &  OutAssetDataList,
bool  bHasBPAsset = false,
bool  bIsFullLoad = false 
)
inlinestatic

Load asset with UObjectLibrary.

Template Parameters
T
Parameters
InAssetsPath
OutAssetDataList
bHasBPAsset
bIsFullLoad
See also
UObjectLibrary
AsyncLoading

◆ LoadObjFromAssetPath()

template<typename T >
static FORCEINLINE T* URRAssetUtils::LoadObjFromAssetPath ( UObject *  Outer,
const FString &  InAssetPath 
)
inlinestatic

This must not be invoked at Sim initialization since it would flush Async loaders away!

Besides, [ConstructorHelpers::FObjectFinder<T> asset(AssetPathName); will call [StaticFindObject()] instead

and requires to be run inside a ctor.

This loads synchronously, thus should be avoided if possible.

Template Parameters
T
Parameters
Outer
InAssetPath
Returns
T*

◆ SaveObjectToAsset()

static UObject* URRAssetUtils::SaveObjectToAsset ( UObject *  InObject,
const FString &  InAssetPath,
bool  bSaveDuplicatedObject = false,
bool  bInStripEditorOnlyContent = false,
bool  bInAsyncSave = true,
bool  bInAlwaysOverwrite = false 
)
static

Save object in memory to asset file on disk.

Parameters
InObject
InAssetPathFull UE asset path of the output asset (eg: /Game/Contents/DynamicContents/SK_Obj)
bSaveDuplicatedObject
bInStripEditorOnlyContent
bInAsyncSavedefault true to avoid block-waiting on data writing to disk
bInAlwaysOverwritedefault false to avoid liberty of overwriting
Returns
true if succeeded
See also
https://forums.unrealengine.com/t/calling-upackage-savepackage-causes-fatal-assert-in-staticfindobjectfast/447917
https://forums.unrealengine.com/t/dynamically-created-primary-assets-not-registering-with-asset-manager/210255
https://forums.unrealengine.com/t/how-to-work-with-cooked-content-in-editor/265094

◆ SaveObjectToAssetInModule()

static UObject* URRAssetUtils::SaveObjectToAssetInModule ( UObject *  InObject,
const ERRResourceDataType  InAssetDataType,
const FString &  InAssetUniqueName,
const TCHAR *  InModuleName,
bool  bSaveDuplicatedObject = false,
bool  bInStripEditorOnlyContent = false,
bool  bInAsyncSave = true,
bool  bInAlwaysOverwrite = false 
)
static

Save object in memory to asset file on disk stored by a module.

Parameters
InObject
InAssetDataType
InAssetUniqueNameUnique name for the output asset
InModuleName
bSaveDuplicatedObject
bInStripEditorOnlyContent
bInAsyncSavedefault true to avoid block-waiting on data writing to disk
bInAlwaysOverwritedefault false to avoid liberty of overwriting
Returns
true if succeeded

◆ SavePackageToAsset()

static bool URRAssetUtils::SavePackageToAsset ( UPackage *  InPackage,
UObject *  InObject,
bool  bInAsyncSave = true,
bool  bInAlwaysOverwrite = false 
)
static

Save package to asset file on disk.

Parameters
InObject
bInAsyncSavedefault true to avoid block-waiting on data writing to disk
bInAlwaysOverwritedefault false to avoid liberty of overwriting
Returns
true if succeeded

The documentation for this class was generated from the following file: