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:\Ue4\UE_4.21\Engine\Binaries\DotNET\AutomationTool.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.0\VC\bin\amd64\link.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.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM