You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

UE蓝图函数库GetPointlessMessage函数无法被搜索到的问题求助

问题排查与修复方案

核心问题分析

你的代码存在三个关键问题,导致蓝图无法识别该函数:

  • GENERATED_BODY() 位置错误:这个宏必须放在类的public区域最顶部,Unreal依赖它生成类的反射代码,放在private区域会导致反射信息不完整。
  • UFUNCTION 宏格式错误:宏定义末尾多了分号,且缺少Category参数——蓝图函数必须指定分类,否则无法在搜索结果中正常显示。
  • 头文件包含顺序错误:CoreMinimal.h是Unreal核心基础定义的入口,必须作为第一个头文件包含,其他头文件应放在其后。

修复后的头文件代码

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "MyBlueprintFunctionLibrary.generated.h"

UCLASS()
class MYPROJECT2_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()
public:
    UFUNCTION(BlueprintCallable, Category="Custom Messages")
    static FString GetPointlessMessage();
protected:
private:
};

修复后的CPP文件(无需修改,保持原样即可)

// Fill out your copyright notice in the Description page of Project Settings.

#include "MyBlueprintFunctionLibrary.h"

FString UMyBlueprintFunctionLibrary::GetPointlessMessage()
{
    return FString(TEXT("Hi guys"));
}

后续操作步骤

  1. 保存修改后的代码,在Visual Studio中重新编译项目。
  2. 编译完成后重启Unreal Editor(避免缓存残留导致的识别异常)。
  3. 在关卡蓝图中搜索GetPointlessMessage,或在Custom Messages分类下找到该函数。

内容的提问来源于stack exchange,提问作者Remmy Dev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 19:05:04