UE4 版本升级记录和一些Bug处理笔记

写个笔记记录做版本升级时以及平常遇到的一些奇葩Bug和问题,方便日后回查,

辣鸡引擎毁我青春!薅我头发!

------------------------------------------------------割------------------------------------------------------------------------

Q.UWebBrowser不支持中文输入法的bug:

继承UWebBrowser,重写Rebuild函数:

TSharedRef<SWidget> UWebBrowserEx::RebuildWidget()
{
    if (IsDesignTime())
    {
        return SNew(SBox)
            .HAlign(HAlign_Center)
            .VAlign(VAlign_Center)
            [
                SNew(STextBlock)
                .Text(LOCTEXT("Web BrowserEx", "Web BrowserEx"))
            ];
    }
    else
    {
        WebBrowserWidget = SNew(SWebBrowser)
            .InitialURL(InitialURL)
            .ShowControls(false)
            .SupportsTransparency(bSupportsTransparency)
            .OnUrlChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, HandleOnUrlChanged))
            .OnBeforePopup(BIND_UOBJECT_DELEGATE(FOnBeforePopupDelegate, HandleOnBeforePopup));
        
     //支持中文输入法 start
if (WebBrowserWidget.IsValid()) { ITextInputMethodSystem* const TextInputMethodSys = FSlateApplication::Get().GetTextInputMethodSystem(); WebBrowserWidget->BindInputMethodSystem(TextInputMethodSys); }
     //支持中文输入法 end
return WebBrowserWidget.ToSharedRef(); } }

Error: ERROR: A conflicting instance of AutomationTool is already running. Curent location: D:Ue4UE_4.21EngineBinariesDotNETAutomationTool.exe. A process manager may be used to determine the conflicting process and what tool may have launched it

  打包时,经常遇到╮(╯▽╰)╭,打开任务结束AutomationTool.exe进程就好(重启也行,手动滑稽)

 4.21:Cast转换时报错:error C2664: “To *TCastImpl<From,To,ECastType::UObjectToInterface>::DoCast(UObject *)”: 无法将参数 1 从“From *”转换为“UObject *”

  这沙雕问题,报错报的不明就里.

  以以下Cast 代码为例.

AGameModeBase* temp_gamemode = UGameplayStatics::GetGameMode(this);
IDemonstrateGameMode* gameModeIns = Cast<IDemonstrateGameMode>(temp_gamemode);

  如果temp_gamemode指针为“指向不完整类型指针”时就会报error C2664.  

  实际问题就是少了在

  .cpp或.h中   #include "GameFramework/GameMode.h"

 4.21:打包时遇到fatal error C1083: 无法打开包括文件"XXXXX.h" No such file or directory

可以Debug启动,打包时就失败了

主要问题:

这沙雕问题,要不是看在我贫穷的份上,我就一jio踢爆公司的RTX Titan机箱了!

1.重复引用

2.#include 路径问题

3.ANSI和UTF-8编码问题

4.插件依赖Module问题

解决方法:

#include 路径问题:

用类似以下栗子的,新的#include路径:

#include "BJ_3DDesignAPP/DemonStrate/Data/DTOData_SceneConfig.h"

代替旧的#include路径:

#include "DemonStrate/Data/DTOData_SceneConfig.h"

note: BJ_3DDesignAPP是我Source的Root目录

 

插件依赖Module问题:

  例如以我经常会用到的Plugin插件VictoryPlugin为例,里面的VictoryBPFunctionLibrary.h 里引用了AIModule里面的东西(Plugin插件的build.cs里已经Private依赖的AIModule)

  然后我在工程中build.cs private依赖了VictoryPlugin插件 并 #include "VictoryBPFunctionLibrary.h” ,打包时可能回报C1083 Error.

  那么可有可能是你忘记在主工程中依赖相关Module,例如忘记依赖AIModule 模块,他就回报 C1083 "AIController.h" No such file or directory

4.21:LogCompile: Error: Cannot expose property to blueprints in a struct that is not a BlueprintType. CppAnimNode_Demonstrate.BasePose

  在做自定义Anim Graph Node遇到的报错.

  把结构体宏USTRUCT() 改成 USTRUCT(BlueprintType)即可

4.15 升至4.16

吐槽:4.15到4.16更新 引擎底层变动真尼玛大。很多报错的方式和写法跟以前完全不一样了~~!

1. Cpp文件报 Expected CppCom_Menu.h to be first header included.

原因:UE4 更改了Build.cs的写法。注解掉 PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs即可

4.18.3 :WebBrowser Plugin绑定UObject时 报错

最近想给WebBrowser 插件 BingUObject 一个C++的UObject 跟HTML页面做些交互。

在写好了代码

void UMainUserWidget::BindJSObject()
{
    this->JSLink = NewObject<UJSBus>(UJSBus::StaticClass());
    this->JSLink->CS = TEXT("ccc");
    this->JSLink->TestStr = TEXT("TestStr");
    FString Name = TEXT("UE_Demo");
    if (JSLink != nullptr) 
    {
        auto wgt_ptr = MainWeb->GetWebWidget();
        wgt_ptr->BindUObject(Name, JSLink);
    }
}

后,

Compile时 报出一下不明真相的错误:

MainUserWidget.cpp.obj : error LNK2019: 

{路径}UE4Editor-{项目名称}.dll : fatal error LNK1120: 1

Error executing C:Program Files (x86)Microsoft Visual Studio 14.0VCinamd64link.exe (tool returned code: 1120)

最后看了看WebBrowser插件的Build.cs发现是缺少了一些Module.然后自己项目的Build.cs

 附JS 交互代码:

 window.ue.myobject.{函数}({参数}).then( function(TheReturnedValue) { console.log(TheReturnedValue); alert(TheReturnedValue)} ).catch( function(error){ console.log(error);alert(error) } );

添加上,编译就通过了。(其他插件类似错误同理)可喜可贺可喜可贺。

4.20.X :错误 C2511 void AMyProjectCharacter::XXX(const FString &)”:“XXX”中没有找到重载的成员函数 XX.gen.cpp 

这报错通常出现于BlueprintImplementableEvent和BlueprintNativeEvent修饰符的UFUnction情况下。

现在版本的BlueprintImplementableEvent和BlueprintNativeEvent修饰符的UFUnction函数FString 的必须是以下格式:

    UFUNCTION(BlueprintImplementableEvent, Category = "Cpp_Event")
        void Event_A(FString &str);

    UFUNCTION(BlueprintNativeEvent, Category = "Cpp_Event")
        void Event_B(FString &str);
        void Event_B_Implementation(FString &str);

4.21.X:ERROR: Non-editor build cannot depend on non-redistributable modules.

 

原文地址:https://www.cnblogs.com/linqing/p/7107015.html