Workind with Assets in Unreal Engine

Published on

How to import various kind of assets to Unreal Engine with C++?

Platforma

An Asset is any piece of content in an Unreal Engine project.

Check if a file exists on a disk

#include "HAL/PlatformFileManager.h" // Core
/**
 * <mark>Check whether a file exists on the disk</mark>
 * @param FilePath	The path of targeted file, e.g. "C:/Temp/MyFile.txt"
 * @param OutInfoMsg    Help for action's result
 * @return The string content of the file
*/
UFUNCTION(BlueprintCallable)
static bool DoesFileExist(FString FilePath, FString& OutInfoMsg);

Open and Close Assets With C++ (Editor only)

Open an editor window for the desired Asset

#include "Kismet/BlueprintFunctionLibrary.h" // Engine
/**
 * Editor Only - Will not work in packaged build.
 * 
 * <mark>Open an editor window for the desired Asset</mark>
 *
 * @param Asset				Asset to open the editor window for
 * @param bOutSuccess		If the action was a success or not
 * @param OutInfoMsg	More information about the action's result
 */
UFUNCTION(BlueprintCallable, Category = "<a href="https://www.youtube.com/watch?v=EYn49I1tk-I" target="_blank" rel="nofollow noopener">Alex Quevillon - Open Asset</a>")
<strong>static void OpenAssetWindow(UObject* Asset, bool& bOutSuccess, FString& OutInfoMsg);</strong>

Close the editor window that is open for the desired Asset

#include "Kismet/BlueprintFunctionLibrary.h" // Engine
/**
 * Editor Only - Will not work in packaged build.
 *
 * <mark>Close the editor window that is open for the desired Asset</mark>
 *
 * @param Asset				Asset to close the editor window for
 * @param bOutSuccess		If the action was a success or not
 * @param OutInfoMsg	More information about the action's result
 */
UFUNCTION(BlueprintCallable, Category = "<a href="https://www.youtube.com/watch?v=EYn49I1tk-I" target="_blank" rel="nofollow noopener">Alex Quevillon - Open Asset</a>")
<strong>static void CloseAssetWindow(UObject* Asset, bool& bOutSuccess, FString& OutInfoMsg);</strong>

Get all the assets that have an editor window open for them

#include "Kismet/BlueprintFunctionLibrary.h" // Engine
/**
 * Editor Only - Will not work in packaged build.
 *
 * <mark>Get all the assets that have an editor window open for them</mark>
 *
 * @param bOutSuccess		If the action was a success or not
 * @param OutInfoMsg		More information about the action's result
 * 
 * @return Assets that are open
 */
UFUNCTION(BlueprintCallable, Category = "<a href="https://www.youtube.com/watch?v=EYn49I1tk-I" target="_blank" rel="nofollow noopener">Alex Quevillon - Open Asset</a>")
<strong>static TArray&lt;UObject*&gt; GetAllAssetsWithOpenedWindow(bool& bOutSuccess, FString& OutInfoMsg);</strong>
Vrealmatic consulting

Anything unclear?

Let us know!

Contact Us