diff --git a/Source/VictoryBPLibrary/Private/VictoryBPFunctionLibrary.cpp b/Source/VictoryBPLibrary/Private/VictoryBPFunctionLibrary.cpp index 3b7e09d..0cd5a3f 100644 --- a/Source/VictoryBPLibrary/Private/VictoryBPFunctionLibrary.cpp +++ b/Source/VictoryBPLibrary/Private/VictoryBPFunctionLibrary.cpp @@ -5748,5 +5748,25 @@ static void TESTINGInternalDrawDebugCircle(const UWorld* InWorld, const FMatrix& } +// Get UClass from asset in AssetRegistry +TArray UVictoryBPFunctionLibrary::GetClassFromAssetData(TArray& InAssetData) +{ + TArray 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 diff --git a/Source/VictoryBPLibrary/Public/VictoryBPFunctionLibrary.h b/Source/VictoryBPLibrary/Public/VictoryBPFunctionLibrary.h index a63f06b..56fd858 100644 --- a/Source/VictoryBPLibrary/Public/VictoryBPFunctionLibrary.h +++ b/Source/VictoryBPLibrary/Public/VictoryBPFunctionLibrary.h @@ -34,6 +34,9 @@ //#include "Engine/Texture2D.h" #include "DDSLoader.h" +//GetClassFromAssetData +#include "Runtime/AssetRegistry/Public/AssetData.h" + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include "VictoryBPFunctionLibrary.generated.h" @@ -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 GetClassFromAssetData(UPARAM(ref) TArray& InAssetData); + }; diff --git a/Source/VictoryBPLibrary/VictoryBPLibrary.Build.cs b/Source/VictoryBPLibrary/VictoryBPLibrary.Build.cs index ba21f90..c23ce83 100644 --- a/Source/VictoryBPLibrary/VictoryBPLibrary.Build.cs +++ b/Source/VictoryBPLibrary/VictoryBPLibrary.Build.cs @@ -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 ... }