Can now switch the skeletal mesh on a character
This commit is contained in:
@@ -20,7 +20,7 @@ void UlxAssetLookup::RebuildIndex()
|
||||
IAssetRegistry::GetChecked().WaitForCompletion();
|
||||
AssetPaths.Empty();
|
||||
AddAssets(TEXT("/Game/StaticMeshes"), UStaticMesh::StaticClass(), TEXT("SM_"));
|
||||
AddAssets(TEXT("/Game/SkeletalMeshes"), USkeletalMesh::StaticClass(), TEXT("SK_"));
|
||||
AddAssets(TEXT("/Game/SkeletalMeshes"), USkeletalMesh::StaticClass(), TEXT("SKM_"));
|
||||
AddAssets(TEXT("/Game/AnimSequences"), UAnimSequence::StaticClass(), TEXT("SEQ_"));
|
||||
AddAssets(TEXT("/Game/Tangibles"), UBlueprint::StaticClass(), TEXT("TAN_"));
|
||||
AddAssets(TEXT("/Game/Widgets"), UWidgetBlueprint::StaticClass(), TEXT("WB_"));
|
||||
@@ -52,16 +52,22 @@ void UlxAssetLookup::AddAssets(const TCHAR *Path, UClass *Class, const TCHAR *Na
|
||||
FoundData.Num(), *Class->GetName(), Path);
|
||||
}
|
||||
|
||||
UObject *UlxAssetLookup::LoadAsset(const UObject *Context, UClass *Class, UClass *ChildOf, const FString &Name, bool ErrorIfNotFound)
|
||||
void UlxAssetLookup::ReportFailedLoad(const FString &ClassName, const FString &Name, const FString &Reason)
|
||||
{
|
||||
static TSet<FString> Reported;
|
||||
FString Key = ClassName + TEXT(":") + Name + TEXT(":") + Reason;
|
||||
if (Reported.Contains(Key)) return;
|
||||
Reported.Add(Key);
|
||||
UE_LOG(LogLuprexIntegration, Display, TEXT("Loading %s %s: %s"), *ClassName, *Name, *Reason);
|
||||
}
|
||||
|
||||
UObject *UlxAssetLookup::LoadAsset(const UObject *Context, UClass *Class, UClass *ChildOf, const FString &Name)
|
||||
{
|
||||
const UlxAssetLookup *Lookup = ALuprexGameModeBase::FromContext(Context)->GetAssetLookup();
|
||||
const FString *Path = Lookup->AssetPaths.Find(MakeTuple(Class->GetName(), FName(Name)));
|
||||
if (Path == nullptr)
|
||||
{
|
||||
if (ErrorIfNotFound)
|
||||
{
|
||||
UE_LOG(LogLuprexIntegration, Error, TEXT("Loading %s %s: asset not found"), *Class->GetName(), *Name);
|
||||
}
|
||||
ReportFailedLoad(Class->GetName(), Name, TEXT("asset not found"));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -77,7 +83,7 @@ UObject *UlxAssetLookup::LoadAsset(const UObject *Context, UClass *Class, UClass
|
||||
|
||||
if (Result == nullptr)
|
||||
{
|
||||
UE_LOG(LogLuprexIntegration, Error, TEXT("Loading %s %s: unknown load failure"), *Class->GetName(), *Name);
|
||||
ReportFailedLoad(Class->GetName(), Name, TEXT("unknown load failure"));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -86,7 +92,7 @@ UObject *UlxAssetLookup::LoadAsset(const UObject *Context, UClass *Class, UClass
|
||||
UClass *ResClass = (UClass *)Result;
|
||||
if (!ResClass->IsChildOf(ChildOf))
|
||||
{
|
||||
UE_LOG(LogLuprexIntegration, Error, TEXT("Loading %s %s: blueprint not a child of %s"), *Class->GetName(), *Name, *ChildOf->GetName());
|
||||
ReportFailedLoad(Class->GetName(), Name, FString::Printf(TEXT("blueprint not a child of %s"), *ChildOf->GetName()));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -95,50 +101,50 @@ UObject *UlxAssetLookup::LoadAsset(const UObject *Context, UClass *Class, UClass
|
||||
}
|
||||
|
||||
ElxValidOrNotValid UlxAssetLookup::LoadStaticMeshAsset(
|
||||
UStaticMesh *&Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||
UStaticMesh *&Result, const UObject *Context, const FString &Name)
|
||||
{
|
||||
Result = (UStaticMesh *)LoadAsset(Context, UStaticMesh::StaticClass(), nullptr, Name, ErrorIfNotFound);
|
||||
Result = (UStaticMesh *)LoadAsset(Context, UStaticMesh::StaticClass(), nullptr, Name);
|
||||
return Result ? Valid : NotValid;
|
||||
}
|
||||
|
||||
ElxValidOrNotValid UlxAssetLookup::LoadSkeletalMeshAsset(
|
||||
USkeletalMesh *&Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||
USkeletalMesh *&Result, const UObject *Context, const FString &Name)
|
||||
{
|
||||
Result = (USkeletalMesh *)LoadAsset(Context, USkeletalMesh::StaticClass(), nullptr, Name, ErrorIfNotFound);
|
||||
Result = (USkeletalMesh *)LoadAsset(Context, USkeletalMesh::StaticClass(), nullptr, Name);
|
||||
return Result ? Valid : NotValid;
|
||||
}
|
||||
|
||||
ElxValidOrNotValid UlxAssetLookup::LoadAnimSequenceAsset(
|
||||
UAnimSequence *&Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||
UAnimSequence *&Result, const UObject *Context, const FString &Name)
|
||||
{
|
||||
Result = (UAnimSequence *)LoadAsset(Context, UAnimSequence::StaticClass(), nullptr, Name, ErrorIfNotFound);
|
||||
Result = (UAnimSequence *)LoadAsset(Context, UAnimSequence::StaticClass(), nullptr, Name);
|
||||
return Result ? Valid : NotValid;
|
||||
}
|
||||
|
||||
ElxValidOrNotValid UlxAssetLookup::LoadTangibleBlueprintAsset(
|
||||
TSubclassOf<AActor> &Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||
TSubclassOf<AActor> &Result, const UObject *Context, const FString &Name)
|
||||
{
|
||||
Result = (UClass*)LoadAsset(Context, UBlueprint::StaticClass(), AActor::StaticClass(), Name, ErrorIfNotFound);
|
||||
Result = (UClass*)LoadAsset(Context, UBlueprint::StaticClass(), AActor::StaticClass(), Name);
|
||||
if (Result == nullptr) return NotValid;
|
||||
UFunction *aqchanged = Result->FindFunctionByName(FName(TEXT("Animation Queue Changed")));
|
||||
if ((aqchanged == nullptr)||(aqchanged->ParmsSize != 0))
|
||||
{
|
||||
UE_LOG(LogLuprexIntegration, Error, TEXT("Loading Blueprint %s: Tangible does not have 'Animation Queue Changed' function"), *Name);
|
||||
ReportFailedLoad(TEXT("Blueprint"), Name, TEXT("tangible does not have 'Animation Queue Changed' function"));
|
||||
Result = nullptr; return NotValid;
|
||||
}
|
||||
return Valid;
|
||||
}
|
||||
|
||||
ElxValidOrNotValid UlxAssetLookup::LoadUserWidgetAsset(
|
||||
TSubclassOf<UUserWidget> &Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||
TSubclassOf<UUserWidget> &Result, const UObject *Context, const FString &Name)
|
||||
{
|
||||
Result = (UClass *)LoadAsset(Context, UWidgetBlueprint::StaticClass(), UUserWidget::StaticClass(), Name, ErrorIfNotFound);
|
||||
Result = (UClass *)LoadAsset(Context, UWidgetBlueprint::StaticClass(), UUserWidget::StaticClass(), Name);
|
||||
return Result ? Valid : NotValid;
|
||||
}
|
||||
|
||||
ElxValidOrNotValid UlxAssetLookup::LoadLuaWidgetAsset(
|
||||
TSubclassOf<UlxLuaWidget> &Result, const UObject *Context, const FString &Name, bool ErrorIfNotFound)
|
||||
TSubclassOf<UlxLuaWidget> &Result, const UObject *Context, const FString &Name)
|
||||
{
|
||||
Result = (UClass *)LoadAsset(Context, UWidgetBlueprint::StaticClass(), UlxLuaWidget::StaticClass(), Name, ErrorIfNotFound);
|
||||
Result = (UClass *)LoadAsset(Context, UWidgetBlueprint::StaticClass(), UlxLuaWidget::StaticClass(), Name);
|
||||
return Result ? Valid : NotValid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user