Overhauling asset loading
This commit is contained in:
BIN
Content/AnimSequences/SEQ_Jump.uasset
LFS
Normal file
BIN
Content/AnimSequences/SEQ_Jump.uasset
LFS
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Content/Widgets/WB_Root.uasset
LFS
BIN
Content/Widgets/WB_Root.uasset
LFS
Binary file not shown.
@@ -7,93 +7,9 @@
|
|||||||
#include "Components/Widget.h"
|
#include "Components/Widget.h"
|
||||||
#include "WidgetBlueprint.h"
|
#include "WidgetBlueprint.h"
|
||||||
#include "Blueprint/UserWidget.h"
|
#include "Blueprint/UserWidget.h"
|
||||||
|
#include "Animation/AnimSequence.h"
|
||||||
#include "Engine/StaticMesh.h"
|
#include "Engine/StaticMesh.h"
|
||||||
|
|
||||||
void UlxAssetLookup::RebuildIndex()
|
|
||||||
{
|
|
||||||
CachedTangibles.Empty();
|
|
||||||
CachedStaticMeshes.Empty();
|
|
||||||
IAssetRegistry::GetChecked().WaitForCompletion();
|
|
||||||
ScanTangibles();
|
|
||||||
ScanStaticMeshes();
|
|
||||||
ScanWidgets();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UlxAssetLookup::ScanTangibles()
|
|
||||||
{
|
|
||||||
TArray<FAssetData> FoundData;
|
|
||||||
FARFilter AssetFilter;
|
|
||||||
AssetFilter.PackagePaths.Add(FName(TEXT("/Game/Tangibles")));
|
|
||||||
AssetFilter.ClassPaths.Add(UBlueprint::StaticClass()->GetClassPathName());
|
|
||||||
AssetFilter.bIncludeOnlyOnDiskAssets = true;
|
|
||||||
AssetFilter.bRecursivePaths = true;
|
|
||||||
IAssetRegistry::GetChecked().GetAssets(AssetFilter, FoundData);
|
|
||||||
|
|
||||||
UE_LOG(LogLuprexIntegration, Display, TEXT("Found %d assets in /Game/Tangibles"), FoundData.Num());
|
|
||||||
for (const FAssetData &Data : FoundData)
|
|
||||||
{
|
|
||||||
FString Path = Data.GetObjectPathString() + TEXT("_C");
|
|
||||||
CachedTangibles.Add(Data.AssetName, Path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UlxAssetLookup::ScanStaticMeshes()
|
|
||||||
{
|
|
||||||
TArray<FAssetData> FoundData;
|
|
||||||
FARFilter AssetFilter;
|
|
||||||
AssetFilter.PackagePaths.Add(FName(TEXT("/Game/StaticMeshes")));
|
|
||||||
AssetFilter.ClassPaths.Add(UStaticMesh::StaticClass()->GetClassPathName());
|
|
||||||
AssetFilter.bIncludeOnlyOnDiskAssets = true;
|
|
||||||
AssetFilter.bRecursivePaths = true;
|
|
||||||
IAssetRegistry::GetChecked().GetAssets(AssetFilter, FoundData);
|
|
||||||
|
|
||||||
UE_LOG(LogLuprexIntegration, Display, TEXT("Found %d assets in /Game/StaticMeshes"), FoundData.Num());
|
|
||||||
for (const FAssetData &Data : FoundData)
|
|
||||||
{
|
|
||||||
FString Path = Data.GetObjectPathString();
|
|
||||||
CachedStaticMeshes.Add(Data.AssetName, Path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UlxAssetLookup::ScanWidgets()
|
|
||||||
{
|
|
||||||
TArray<FAssetData> FoundData;
|
|
||||||
FARFilter AssetFilter;
|
|
||||||
AssetFilter.PackagePaths.Add(FName(TEXT("/Game/Widgets")));
|
|
||||||
AssetFilter.ClassPaths.Add(UWidgetBlueprint::StaticClass()->GetClassPathName());
|
|
||||||
AssetFilter.bIncludeOnlyOnDiskAssets = true;
|
|
||||||
AssetFilter.bRecursivePaths = true;
|
|
||||||
IAssetRegistry::GetChecked().GetAssets(AssetFilter, FoundData);
|
|
||||||
|
|
||||||
UE_LOG(LogLuprexIntegration, Display, TEXT("Found %d assets in /Game/Widgets"), FoundData.Num());
|
|
||||||
for (const FAssetData &Data : FoundData)
|
|
||||||
{
|
|
||||||
FString Path = Data.GetObjectPathString() + TEXT("_C");
|
|
||||||
CachedWidgets.Add(Data.AssetName, Path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FString UlxAssetLookup::TangibleLoadPath(const FName &AssetName) const
|
|
||||||
{
|
|
||||||
const FString *Result = CachedTangibles.Find(AssetName);
|
|
||||||
if (Result == nullptr) return TEXT("");
|
|
||||||
return *Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
FString UlxAssetLookup::StaticMeshLoadPath(const FName &AssetName) const
|
|
||||||
{
|
|
||||||
const FString *Result = CachedStaticMeshes.Find(AssetName);
|
|
||||||
if (Result == nullptr) return TEXT("");
|
|
||||||
return *Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
FString UlxAssetLookup::WidgetLoadPath(const FName &AssetName) const
|
|
||||||
{
|
|
||||||
const FString *Result = CachedWidgets.Find(AssetName);
|
|
||||||
if (Result == nullptr) return TEXT("");
|
|
||||||
return *Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UlxAssetLookup::LogMaybeError(bool Error, const TCHAR *Message, const TCHAR *Path)
|
void UlxAssetLookup::LogMaybeError(bool Error, const TCHAR *Message, const TCHAR *Path)
|
||||||
{
|
{
|
||||||
if (Error)
|
if (Error)
|
||||||
@@ -106,94 +22,154 @@ void UlxAssetLookup::LogMaybeError(bool Error, const TCHAR *Message, const TCHAR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UStaticMesh *UlxAssetLookup::LoadStaticMeshAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
|
||||||
{
|
|
||||||
ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(Context);
|
|
||||||
FString Path = mode->GetAssetLookup()->StaticMeshLoadPath(FName(FString("SM_") + Name));
|
|
||||||
if (Path.IsEmpty())
|
|
||||||
{
|
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Static mesh not on search path"), *Name);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
UStaticMesh *Result = LoadObject<UStaticMesh>(nullptr, *Path);
|
|
||||||
if (Result == nullptr)
|
|
||||||
{
|
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Cannot load static mesh"), *Path);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
const ElxValidOrNotValid NotValid = ElxValidOrNotValid::NotValid;
|
||||||
|
const ElxValidOrNotValid Valid = ElxValidOrNotValid::Valid;
|
||||||
|
|
||||||
|
void UlxAssetLookup::RebuildIndex()
|
||||||
|
{
|
||||||
|
IAssetRegistry::GetChecked().WaitForCompletion();
|
||||||
|
AssetPaths.Empty();
|
||||||
|
AddAssets(TEXT("/Game/StaticMeshes"), UStaticMesh::StaticClass(), TEXT("SM_"));
|
||||||
|
AddAssets(TEXT("/Game/AnimSequences"), UAnimSequence::StaticClass(), TEXT("SEQ_"));
|
||||||
|
AddAssets(TEXT("/Game/Tangibles"), UBlueprint::StaticClass(), TEXT("TAN_"));
|
||||||
|
AddAssets(TEXT("/Game/Widgets"), UWidgetBlueprint::StaticClass(), TEXT("WB_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TSubclassOf<AActor> UlxAssetLookup::LoadTangibleBlueprintAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound) {
|
void UlxAssetLookup::AddAssets(const TCHAR *Path, const UClass *Class, const TCHAR *NamePrefix)
|
||||||
ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(Context);
|
{
|
||||||
FString Path = mode->GetAssetLookup()->TangibleLoadPath(FName(FString("TAN_") + Name));
|
TArray<FAssetData> FoundData;
|
||||||
|
TMap<FName, FString> Result;
|
||||||
|
FARFilter AssetFilter;
|
||||||
|
AssetFilter.PackagePaths.Add(FName(Path));
|
||||||
|
AssetFilter.ClassPaths.Add(Class->GetClassPathName());
|
||||||
|
AssetFilter.bIncludeOnlyOnDiskAssets = true;
|
||||||
|
AssetFilter.bRecursivePaths = true;
|
||||||
|
IAssetRegistry::GetChecked().GetAssets(AssetFilter, FoundData);
|
||||||
|
FString FSNamePrefix(NamePrefix);
|
||||||
|
|
||||||
|
for (const FAssetData &Data : FoundData)
|
||||||
|
{
|
||||||
|
FString AssetName = Data.AssetName.ToString();
|
||||||
|
if (AssetName.StartsWith(FSNamePrefix))
|
||||||
|
{
|
||||||
|
FName ShortName(AssetName.RightChop(FSNamePrefix.Len()));
|
||||||
|
AssetPaths.Add(MakeTuple(Class->GetName(), ShortName), Data.GetObjectPathString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UE_LOG(LogLuprexIntegration, Display, TEXT("Found %d assets of type %s in %s"),
|
||||||
|
FoundData.Num(), *Class->GetName(), Path);
|
||||||
|
}
|
||||||
|
|
||||||
|
FString UlxAssetLookup::GetAssetPath(const UObject *Context, const UClass *Class, const FString &Name)
|
||||||
|
{
|
||||||
|
const UlxAssetLookup *Lookup = ALuprexGameModeBase::FromContext(Context)->GetAssetLookup();
|
||||||
|
const FString *Path = Lookup->AssetPaths.Find(MakeTuple(Class->GetName(), FName(Name)));
|
||||||
|
if (Path == nullptr)
|
||||||
|
{
|
||||||
|
return FString();
|
||||||
|
}
|
||||||
|
return *Path;
|
||||||
|
}
|
||||||
|
|
||||||
|
ElxValidOrNotValid UlxAssetLookup::LoadStaticMeshAsset(
|
||||||
|
UStaticMesh *&Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||||
|
{
|
||||||
|
Result = nullptr;
|
||||||
|
FString Path = GetAssetPath(Context, UStaticMesh::StaticClass(), Name);
|
||||||
if (Path.IsEmpty())
|
if (Path.IsEmpty())
|
||||||
{
|
{
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Tangible not on search path"), *Name);
|
LogMaybeError(ErrorIfNotFound, TEXT("Static Mesh not found"), *Name);
|
||||||
return nullptr;
|
Result = nullptr; return NotValid;
|
||||||
}
|
}
|
||||||
UClass *Result = LoadObject<UClass>(nullptr, *Path);
|
Result = LoadObject<UStaticMesh>(nullptr, *Path);
|
||||||
if (Result == nullptr)
|
if (Result == nullptr)
|
||||||
{
|
{
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Cannot load tangible class"), *Path);
|
LogMaybeError(ErrorIfNotFound, TEXT("Cannot load Static Mesh"), *Path);
|
||||||
return nullptr;
|
Result = nullptr; return NotValid;
|
||||||
}
|
}
|
||||||
if (!Result->IsChildOf(AActor::StaticClass()))
|
return Valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
ElxValidOrNotValid UlxAssetLookup::LoadAnimSequenceAsset(
|
||||||
|
UAnimSequence *&Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||||
|
{
|
||||||
|
Result = nullptr;
|
||||||
|
FString Path = GetAssetPath(Context, UAnimSequence::StaticClass(), Name);
|
||||||
|
if (Path.IsEmpty())
|
||||||
{
|
{
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Tangible class is not an actor"), *Path);
|
LogMaybeError(ErrorIfNotFound, TEXT("Anim Sequence not found"), *Name);
|
||||||
return nullptr;
|
Result = nullptr; return NotValid;
|
||||||
|
}
|
||||||
|
Result = LoadObject<UAnimSequence>(nullptr, *Path);
|
||||||
|
if (Result == nullptr)
|
||||||
|
{
|
||||||
|
LogMaybeError(ErrorIfNotFound, TEXT("Cannot load Anim Sequence"), *Path);
|
||||||
|
Result = nullptr; return NotValid;
|
||||||
|
}
|
||||||
|
return Valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
ElxValidOrNotValid UlxAssetLookup::LoadTangibleBlueprintAsset(
|
||||||
|
TSubclassOf<AActor> &Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||||
|
{
|
||||||
|
FString Path = GetAssetPath(Context, UBlueprint::StaticClass(), Name);
|
||||||
|
if (Path.IsEmpty())
|
||||||
|
{
|
||||||
|
LogMaybeError(ErrorIfNotFound, TEXT("Tangible not found"), *Name);
|
||||||
|
Result = nullptr; return NotValid;
|
||||||
|
}
|
||||||
|
Result = LoadClass<AActor>(nullptr, *UnderscoreC(Path));
|
||||||
|
if (Result == nullptr)
|
||||||
|
{
|
||||||
|
LogMaybeError(ErrorIfNotFound, TEXT("Tangible load failed, not an actor blueprint"), *Path);
|
||||||
|
Result = nullptr; return NotValid;
|
||||||
}
|
}
|
||||||
UFunction *aqchanged = Result->FindFunctionByName(FName(TEXT("Animation Queue Changed")));
|
UFunction *aqchanged = Result->FindFunctionByName(FName(TEXT("Animation Queue Changed")));
|
||||||
if ((aqchanged == nullptr)||(aqchanged->ParmsSize != 0))
|
if ((aqchanged == nullptr)||(aqchanged->ParmsSize != 0))
|
||||||
{
|
{
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Tangible does not have 'Animation Queue Changed' function"), *Path);
|
LogMaybeError(ErrorIfNotFound, TEXT("Tangible does not have 'Animation Queue Changed' function"), *Path);
|
||||||
return nullptr;
|
Result = nullptr; return NotValid;
|
||||||
}
|
}
|
||||||
return Result;
|
return Valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSubclassOf<UUserWidget> UlxAssetLookup::LoadUserWidgetAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound) {
|
ElxValidOrNotValid UlxAssetLookup::LoadUserWidgetAsset(
|
||||||
ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(Context);
|
TSubclassOf<UUserWidget> &Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||||
FString Path = mode->GetAssetLookup()->WidgetLoadPath(FName(FString("WB_") + Name));
|
{
|
||||||
|
Result = nullptr;
|
||||||
|
FString Path = GetAssetPath(Context, UWidgetBlueprint::StaticClass(), Name);
|
||||||
|
if (Path.IsEmpty())
|
||||||
|
{
|
||||||
|
LogMaybeError(ErrorIfNotFound, TEXT("Widget not Found"), *Name);
|
||||||
|
Result = nullptr; return NotValid;
|
||||||
|
}
|
||||||
|
Result = LoadClass<UUserWidget>(nullptr, *UnderscoreC(Path));
|
||||||
|
if (Result == nullptr)
|
||||||
|
{
|
||||||
|
LogMaybeError(ErrorIfNotFound, TEXT("Cannot load widget, not a UUserWidget"), *Path);
|
||||||
|
Result = nullptr; return NotValid;
|
||||||
|
}
|
||||||
|
return Valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
ElxValidOrNotValid UlxAssetLookup::LoadLuaWidgetAsset(
|
||||||
|
TSubclassOf<UlxLuaWidget> &Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||||
|
{
|
||||||
|
Result = nullptr;
|
||||||
|
FString Path = GetAssetPath(Context, UWidgetBlueprint::StaticClass(), Name);
|
||||||
if (Path.IsEmpty())
|
if (Path.IsEmpty())
|
||||||
{
|
{
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Widget not on search path"), *Name);
|
LogMaybeError(ErrorIfNotFound, TEXT("Widget not on search path"), *Name);
|
||||||
return nullptr;
|
Result = nullptr; return NotValid;
|
||||||
}
|
}
|
||||||
UClass *Result = LoadObject<UClass>(nullptr, *Path);
|
Result = LoadClass<UlxLuaWidget>(nullptr, *UnderscoreC(Path));
|
||||||
if (Result == nullptr)
|
if (Result == nullptr)
|
||||||
{
|
{
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Cannot load widget blueprint"), *Path);
|
LogMaybeError(ErrorIfNotFound, TEXT("Cannot load widget, not a UlxLuaWidget"), *Path);
|
||||||
return nullptr;
|
Result = nullptr; return NotValid;
|
||||||
}
|
}
|
||||||
if (!Result->IsChildOf(UUserWidget::StaticClass()))
|
return Valid;
|
||||||
{
|
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Blueprint does not derive from UUserWidget"), *Path);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
TSubclassOf<UlxLuaWidget> UlxAssetLookup::LoadLuaWidgetAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound) {
|
|
||||||
ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(Context);
|
|
||||||
FString Path = mode->GetAssetLookup()->WidgetLoadPath(FName(FString("WB_") + Name));
|
|
||||||
if (Path.IsEmpty())
|
|
||||||
{
|
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Widget not on search path"), *Name);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
UClass *Result = LoadObject<UClass>(nullptr, *Path);
|
|
||||||
if (Result == nullptr)
|
|
||||||
{
|
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Cannot load widget blueprint"), *Path);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
if (!Result->IsChildOf(UlxLuaWidget::StaticClass()))
|
|
||||||
{
|
|
||||||
LogMaybeError(ErrorIfNotFound, TEXT("Blueprint does not derive from UlxLuaWidget"), *Path);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,14 @@
|
|||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "UObject/NoExportTypes.h"
|
#include "UObject/NoExportTypes.h"
|
||||||
#include "CommonTypes.h"
|
#include "CommonTypes.h"
|
||||||
|
#include "Templates/Tuple.h"
|
||||||
#include "AssetLookup.generated.h"
|
#include "AssetLookup.generated.h"
|
||||||
|
|
||||||
class AActor;
|
class AActor;
|
||||||
class UUserWidget;
|
class UUserWidget;
|
||||||
class UlxLookAtWidget;
|
class UlxLookAtWidget;
|
||||||
class UStaticMesh;
|
class UStaticMesh;
|
||||||
|
class UAnimSequence;
|
||||||
|
|
||||||
UCLASS(MinimalAPI)
|
UCLASS(MinimalAPI)
|
||||||
class UlxAssetLookup : public UObject
|
class UlxAssetLookup : public UObject
|
||||||
@@ -17,50 +19,56 @@ class UlxAssetLookup : public UObject
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Map from asset name to full loadable path.
|
//
|
||||||
UPROPERTY()
|
// At initialization time, we scan the asset directories
|
||||||
TMap<FName, FString> CachedTangibles;
|
// to see what assets are present. These maps store the
|
||||||
|
// result of the scan. Each entry in the map contains a
|
||||||
// Map from asset name to to full loadable path.
|
// classname, a short name, and a path:
|
||||||
UPROPERTY()
|
//
|
||||||
TMap<FName, FString> CachedStaticMeshes;
|
// <UAnimSequence, Jump> -> "/Game/AnimSequences/SEQ_Jump"
|
||||||
|
//
|
||||||
// Map from asset name to full loadable path.
|
TMap<TTuple<FString, FName>, FString> AssetPaths;
|
||||||
UPROPERTY()
|
|
||||||
TMap<FName, FString> CachedWidgets;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ScanTangibles();
|
|
||||||
void ScanStaticMeshes();
|
|
||||||
void ScanWidgets();
|
|
||||||
|
|
||||||
static void LogMaybeError(bool ErrorIfNotFound, const TCHAR *Format, const TCHAR *Data);
|
void AddAssets(const TCHAR *Path, const UClass *Class, const TCHAR *NamePrefix);
|
||||||
|
|
||||||
|
static FString GetAssetPath(const UObject *Context, const UClass *Class, const FString &Name);
|
||||||
|
|
||||||
|
static void LogMaybeError(bool Error, const TCHAR *Message, const TCHAR *Path);
|
||||||
|
|
||||||
|
static FString UnderscoreC(const FString &Name) { return Name + FString(TEXT("_C")); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void RebuildIndex();
|
void RebuildIndex();
|
||||||
|
|
||||||
// Get the full LoadObject path of a Tangible.
|
|
||||||
FString TangibleLoadPath(const FName &AssetName) const;
|
|
||||||
|
|
||||||
// Get the full LoadObject path of a Static Mesh.
|
|
||||||
FString StaticMeshLoadPath(const FName &AssetName) const;
|
|
||||||
|
|
||||||
// Get the full LoadObject path of a Widget Blueprint.
|
|
||||||
FString WidgetLoadPath(const FName &AssetName) const;
|
|
||||||
|
|
||||||
// Get a static mesh by name
|
// Get a static mesh by name
|
||||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Asset Loading")
|
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
|
||||||
static UStaticMesh *LoadStaticMeshAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
static ElxValidOrNotValid LoadStaticMeshAsset(
|
||||||
|
UStaticMesh *&Result,
|
||||||
|
const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||||
|
|
||||||
|
// Get an animation sequence by name.
|
||||||
|
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
|
||||||
|
static ElxValidOrNotValid LoadAnimSequenceAsset(
|
||||||
|
UAnimSequence *&Result,
|
||||||
|
const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||||
|
|
||||||
// Get a tangible class by name
|
// Get a tangible class by name
|
||||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Asset Loading")
|
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
|
||||||
static TSubclassOf<AActor> LoadTangibleBlueprintAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
static ElxValidOrNotValid LoadTangibleBlueprintAsset(
|
||||||
|
TSubclassOf<AActor> &Result,
|
||||||
|
const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||||
|
|
||||||
// Get a widget blueprint by name
|
// Get a widget blueprint by name
|
||||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Asset Loading")
|
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
|
||||||
static TSubclassOf<UUserWidget> LoadUserWidgetAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
static ElxValidOrNotValid LoadUserWidgetAsset(
|
||||||
|
TSubclassOf<UUserWidget> &Result,
|
||||||
|
const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||||
|
|
||||||
// Get a look-at widget blueprint by name
|
// Get a look-at widget blueprint by name
|
||||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Asset Loading")
|
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
|
||||||
static TSubclassOf<UlxLuaWidget> LoadLuaWidgetAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
static ElxValidOrNotValid LoadLuaWidgetAsset(
|
||||||
|
TSubclassOf<UlxLuaWidget> &Result,
|
||||||
|
const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -59,11 +59,12 @@ void UlxTangible::SetActorBlueprint(const FString &XName) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UClass *blueprint = UlxAssetLookup::LoadTangibleBlueprintAsset(this, Name);
|
TSubclassOf<AActor> Blueprint;
|
||||||
if (blueprint == nullptr)
|
UlxAssetLookup::LoadTangibleBlueprintAsset(Blueprint, this, Name);
|
||||||
|
if (Blueprint == nullptr)
|
||||||
{
|
{
|
||||||
blueprint = UlxAssetLookup::LoadTangibleBlueprintAsset(this, DEFAULT_BLUEPRINT);
|
UlxAssetLookup::LoadTangibleBlueprintAsset(Blueprint, this, DEFAULT_BLUEPRINT);
|
||||||
check(blueprint != nullptr);
|
check(Blueprint != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the blueprint name
|
// Update the blueprint name
|
||||||
@@ -109,7 +110,7 @@ void UlxTangible::SetActorBlueprint(const FString &XName) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
UE_LOG(LogLuprexIntegration, Display, TEXT("Creating Actor: %s"), *params.Name.ToString());
|
UE_LOG(LogLuprexIntegration, Display, TEXT("Creating Actor: %s"), *params.Name.ToString());
|
||||||
AActor* a = w->SpawnActor(blueprint, &transform, params);
|
AActor* a = w->SpawnActor(Blueprint, &transform, params);
|
||||||
check(a != nullptr);
|
check(a != nullptr);
|
||||||
CurrentActor = a;
|
CurrentActor = a;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user