i’m trying to collect all material and material instance but i can’t access any material instance what can i do?
CompilerActor.cpp;
#include "CompilerActor.h"
#include "AssetRegistry/AssetRegistryModule.h"
#include "Materials/Material.h"
#include "AssetRegistry/AssetData.h"
// Sets default values
ACompilerActor::ACompilerActor()
{
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void ACompilerActor::BeginPlay()
{
Super::BeginPlay();
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
AssetRegistryModule.Get().SearchAllAssets(true);
AssetData.Empty();
AssetRegistryModule.Get().GetAssetsByClass(UMaterial::StaticClass()->GetFName(), AssetData);
AssetRegistryModule.Get().GetAssetsByClass(UMaterialFunction::StaticClass()->GetFName(), AssetData);
AssetRegistryModule.Get().GetAssetsByClass(UMaterialInstance::StaticClass()->GetFName(), AssetData);
for (int32 i = 0; i < AssetData.Num(); ++i)
{
FAssetData& Asset = AssetData[i];
UE_LOG(LogTemp, Warning, TEXT("Asset: %s, Class: %s, Path: %s"), *Asset.AssetName.ToString(), *Asset.AssetClass.ToString(), *Asset.PackagePath.ToString());
}
}
// Called every frame
void ACompilerActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
CompilerActor.h;
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CompilerActor.generated.h"
UCLASS()
class CHARACTERCREATORV2_API ACompilerActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ACompilerActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FAssetData> AssetData;
};
this code return 1168 material and material function but 0 material instance.
i’m sure i’m using correct class type according to this doc Materials | Unreal Engine Documentation. is there any different way to access material instance?