Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Source/VictoryBPLibrary/Private/VictoryBPFunctionLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5748,5 +5748,25 @@ static void TESTINGInternalDrawDebugCircle(const UWorld* InWorld, const FMatrix&
}


// Get UClass from asset in AssetRegistry
TArray<UClass*> UVictoryBPFunctionLibrary::GetClassFromAssetData(TArray<FAssetData>& InAssetData)
{
TArray<UClass*> ClassArrayOut;
ClassArrayOut.Empty();
// Iterate over retrieved blueprint assets
for (FAssetData asset : InAssetData)
{
FString ObjPath = asset.ObjectPath.ToString().Append("_C");
UE_LOG(LogTemp, Warning, TEXT("Object path is : %s"), *ObjPath);
UE_LOG(LogTemp, Warning, TEXT("Trying to return BPClass!"));

//Get UClass
ClassArrayOut.Add(StaticLoadClass(UObject::StaticClass(), NULL, *ObjPath, NULL, LOAD_None, NULL));
}

return ClassArrayOut;

}


#undef LOCTEXT_NAMESPACE
15 changes: 15 additions & 0 deletions Source/VictoryBPLibrary/Public/VictoryBPFunctionLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
//#include "Engine/Texture2D.h"
#include "DDSLoader.h"

//GetClassFromAssetData
#include "Runtime/AssetRegistry/Public/AssetData.h"

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#include "VictoryBPFunctionLibrary.generated.h"
Expand Down Expand Up @@ -2002,5 +2005,17 @@ static FString AppendMultiple(FString A, FString B);

//~~~ Mhousse ~~~

/**
* Get UClass from assets found with AssetManager (Purple Class node)
* Use this to get Assets by Path, Class Type ect.
* Use GET ASSET REGISTRY node -> GET ASSETS node -> as your input to this
* Using correct class checking and casting, this can be used for spawning actors, getting class defaults, using textures, sounds ect.
* COOKED BUILDS: : Make sure your assets/folders are manually added to cooked build if they are not used directly in Editor.
* On-the-fly asset list creation or add DLC content, no lookup tables!
*/

UFUNCTION(BlueprintCallable, Category = "Victory BP Library|Misc")
static TArray<UClass*> GetClassFromAssetData(UPARAM(ref) TArray<FAssetData>& InAssetData);

};

3 changes: 2 additions & 1 deletion Source/VictoryBPLibrary/VictoryBPLibrary.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public VictoryBPLibrary(ReadOnlyTargetRules Target) : base(Target)
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core"
"Core",
"AssetRegistry"

// ... add other public dependencies that you statically link with here ...
}
Expand Down