Agrarsense
Static Public Member Functions | Static Private Member Functions | List of all members
UMapUtilities Class Reference

#include <MapUtilities.h>

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

Static Public Member Functions

static TArray< FString > GetAllMapNames (bool onlyAgrarsenseMapFolder=true, bool logResults=false)
 
static TArray< FString > GetAllMapPaths (bool onlyAgrarsenseMapFolder=true, bool logResults=false)
 
static TArray< FAssetData > GetAllMapAssetDatas (bool onlyAgrarsenseMapFolder=true)
 

Static Private Member Functions

static TArray< FAssetData > GetAssetData (bool onlyAgrarsenseMapFolder)
 

Detailed Description

A class for map related utilies.

Definition at line 18 of file MapUtilities.h.

Member Function Documentation

◆ GetAllMapAssetDatas()

TArray< FAssetData > UMapUtilities::GetAllMapAssetDatas ( bool  onlyAgrarsenseMapFolder = true)
static

Get all maps with its full FAssetData information in the whole project or just Agrarsense map folder.

Parameters
onlyAgrarsenseMapFolderShould we only look up path where all Agrarsense maps are or the entire Unreal project
Returns
array of maps FAssetData which contains map name, path etc.

Definition at line 61 of file MapUtilities.cpp.

62{
63 TArray<FAssetData> AssetDatas = GetAssetData(onlyAgrarsenseMapFolder);
64
65 return AssetDatas;
66}
static TArray< FAssetData > GetAssetData(bool onlyAgrarsenseMapFolder)

References GetAssetData().

◆ GetAllMapNames()

TArray< FString > UMapUtilities::GetAllMapNames ( bool  onlyAgrarsenseMapFolder = true,
bool  logResults = false 
)
static

Get all map names in the whole project or just Agrarsense map folder.

Parameters
onlyAgrarsenseMapFolderShould we only look up path where all Agrarsense maps are or the entire Unreal project
logResultsshould results be logged to console
Returns
array of string

Definition at line 9 of file MapUtilities.cpp.

10{
11 TArray<FAssetData> AssetDatas = GetAssetData(onlyAgrarsenseMapFolder);
12
13 TArray<FString> mapNames = TArray<FString>();
14 for (int32 i = 0; i < AssetDatas.Num(); ++i)
15 {
16 FAssetData& mapAssetData = AssetDatas[i];
17 auto name = mapAssetData.AssetName.ToString();
18 mapNames.Add(name);
19 }
20
21#if WITH_EDITOR
22 if (logResults)
23 {
24 UE_LOG(LogTemp, Warning, TEXT("Found %d maps. Map names:"), AssetDatas.Num());
25 for (int i = 0; i < mapNames.Num(); i++)
26 {
27 UE_LOG(LogTemp, Warning, TEXT("%s"), *mapNames[i]);
28 }
29 }
30#endif
31
32 return mapNames;
33}

References GetAssetData().

◆ GetAllMapPaths()

TArray< FString > UMapUtilities::GetAllMapPaths ( bool  onlyAgrarsenseMapFolder = true,
bool  logResults = false 
)
static

Get all map paths in the whole project or just Agrarsense map folder.

Parameters
onlyAgrarsenseMapFolderShould we only look up path where all Agrarsense maps are or the entire Unreal project
logResultsshould results be logged to console
Returns
array of string

Definition at line 35 of file MapUtilities.cpp.

36{
37 TArray<FAssetData> AssetDatas = GetAssetData(onlyAgrarsenseMapFolder);
38
39 TArray<FString> mapPaths = TArray<FString>();
40 for (int32 i = 0; i < AssetDatas.Num(); ++i)
41 {
42 FAssetData& mapAssetData = AssetDatas[i];
43 auto name = mapAssetData.PackagePath.ToString();
44 mapPaths.Add(name);
45 }
46
47#if WITH_EDITOR
48 if (logResults)
49 {
50 UE_LOG(LogTemp, Warning, TEXT("Found %d maps. Map paths:"), AssetDatas.Num());
51 for (int i = 0; i < mapPaths.Num(); i++)
52 {
53 UE_LOG(LogTemp, Warning, TEXT("%s"), *mapPaths[i]);
54 }
55 }
56#endif
57
58 return mapPaths;
59}

References GetAssetData().

◆ GetAssetData()

TArray< FAssetData > UMapUtilities::GetAssetData ( bool  onlyAgrarsenseMapFolder)
staticprivate

Private function to actually retrieve the maps FAssetData

Parameters
onlyAgrarsenseMapFolderShould we only look up path where all Agrarsense maps are or the entire Unreal project
Returns
array of maps FAssetData

Definition at line 68 of file MapUtilities.cpp.

69{
70 FString path = "/Game/"; // Search the whole project
71 if (onlyAgrarsenseMapFolder)
72 {
73 path = "/Game/Agrarsense/Maps"; // Search only in Agrarsense map folder
74 }
75
76 auto ObjectLibrary = UObjectLibrary::CreateLibrary(UWorld::StaticClass(), false, true);
77 ObjectLibrary->LoadAssetDataFromPath(path);
78 TArray<FAssetData> AssetDatas;
79 ObjectLibrary->GetAssetDataList(AssetDatas);
80
81 return AssetDatas;
82}

Referenced by GetAllMapAssetDatas(), GetAllMapNames(), and GetAllMapPaths().


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