目录
1.添加依赖
在项目.Build.cs文件中添加 RHI 模块
PublicDependencyModuleNames.AddRange(new string[] {
"Core",
"CoreUObject",
"Engine",
"RHI",
});
2.新建C++蓝图函数库
名字可以自定义, 我的叫 CustomBlueprintFuntionLibrary
3. 添加函数
.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "CustomBlueprintFunctionLibrary.generated.h"
/**
*
*/
UCLASS()
class SCIENCEANDGOLDCITY_API UCustomBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable)
static FString GetGPUDriverVersion();
}
.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "CustomBlueprintFunctionLibrary.h"
#include "GenericPlatform/GenericPlatformDriver.h"
FString UCustomBlueprintFunctionLibrary::GetGPUDriverVersion()
{
FGPUDriverInfo GPUDriverInfo = FPlatformMisc::GetGPUDriverInfo(GRHIAdapterName);
return GPUDriverInfo.InternalDriverVersion;
}
4. 调用函数
打开关卡蓝图,在BeginPlay处调用刚写的函数,也可以在return处加断点查看详细信息。