插件内容
直接照搬的UTexture2DArray, UTexture2DArrayFactory以及Texture2DArrayResource
目的是改写UTexture2DArray#updateResource的部分源码,还未改动就发现编译通过不了.
希望大佬帮忙解惑,感激不尽.
SkeletalMesh2DStarter.zip (13.0 MB)
SkeletalMesh2DStarter.cpp
#include "SkeletalMesh2DStarter.h"
#include "ContentBrowserMenuContexts.h"
#include "ToolMenus.h"
#include "Misc/NamePermissionList.h"
#include "Misc/PackageName.h"
#include "Engine/Texture2DArray.h"
#include "IAssetTools.h"
#include "IContentBrowserSingleton.h"
#include "ContentBrowserModule.h"
#include "Texture2DArrayEx.h"
#include "Texture2DArrayFactoryEx.h"
#include "ToolMenu.h"
#include "ToolMenuSection.h"
#define LOCTEXT_NAMESPACE "FSkeletalMesh2DStarterModule"
void ExecuteCreateTextureArrayEx(const FToolMenuContext& MenuContext)
{
const UContentBrowserAssetContextMenuContext* Context = UContentBrowserAssetContextMenuContext::FindContextWithAssets(MenuContext);
TArray<UTexture2D*> SelectedTextures = Context->LoadSelectedObjects<UTexture2D>();
if(SelectedTextures.Num() > 0)
{
const FString DefaultSuffix = TEXT("_Array");
FString Name;
FString PackagePath;
IAssetTools::Get().CreateUniqueAssetName(SelectedTextures[0]->GetOutermost()->GetName(), DefaultSuffix, PackagePath, Name);
// Create the factory used to generate the asset.
UTexture2DArrayFactoryEx* Factory = NewObject<UTexture2DArrayFactoryEx>();
Factory->InitialTextures.Empty();
// Give the selected textures to the factory.
for (int32 TextureIndex = 0; TextureIndex < SelectedTextures.Num(); ++TextureIndex)
{
Factory->InitialTextures.Add(SelectedTextures[TextureIndex]);
}
{
const FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
ContentBrowserModule.Get().CreateNewAsset(Name, FPackageName::GetLongPackagePath(PackagePath), UTexture2DArray::StaticClass(), Factory);
}
}
}
void FSkeletalMesh2DStarterModule::StartupModule()
{
UToolMenu* Menu = UE::ContentBrowser::ExtendToolMenu_AssetContextMenu(UTexture2D::StaticClass());
FToolMenuSection& Section = Menu->FindOrAddSection("GetAssetActions");
Section.AddDynamicEntry(NAME_None, FNewToolMenuSectionDelegate::CreateLambda([](FToolMenuSection& InSection)
{
const TSharedRef<FPathPermissionList> ClassPathPermissionList = IAssetTools::Get().GetAssetClassPathPermissionList(EAssetClassAction::CreateAsset);
if (ClassPathPermissionList->PassesFilter(UTexture2DArrayEx::StaticClass()->GetClassPathName().ToString()))
{
static const auto AllowTextureArrayAssetCreationVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.AllowTexture2DArrayCreation"));
if (AllowTextureArrayAssetCreationVar->GetValueOnGameThread() != 0)
{
const TAttribute<FText> Label = LOCTEXT("Texture_Texture2DArray", "Create Texture Array Extension");
const TAttribute<FText> ToolTip = LOCTEXT("Texture_CreateTexture2DArrayTooltip", "Creates a new texture array extension.");
const FSlateIcon Icon = FSlateIcon(FAppStyle::GetAppStyleSetName(), "ClassIcon.Texture2D");
const FToolMenuExecuteAction UIAction = FToolMenuExecuteAction::CreateStatic(&ExecuteCreateTextureArrayEx);
InSection.AddMenuEntry("Texture_Texture2DArray", Label, ToolTip, Icon, UIAction);
}
}
}));
}
SkeletalMesh2DStarter.Build.cs
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Engine",
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Engine",
"AssetTools",
"ImageCore",
"RenderCore",
"ContentBrowser",
"ToolMenus",
"UnrealEd",
"RHI",
"RHICore",
"Slate",
"SlateCore",
"ApplicationCore",
}
);
报错信息
11>Texture2DArrayEx.cpp.obj: Error LNK2019 : 无法解析的外部符号 "public: struct FTextureSource::FMipAllocation & __cdecl FTextureSource::FMipAllocation::operator=(struct FTextureSource::FMipAllocation &&)" (??4FMipAllocation@FTextureSource@@QEAAAEAU01@$$QEAU01@@Z),函数 "public: struct FTextureSource & __cdecl FTextureSource::operator=(struct FTextureSource &&)" (??4FTextureSource@@QEAAAEAU0@$$QEAU0@@Z) 中引用了该符号
11>Texture2DArrayEx.cpp.obj: Error LNK2019 : 无法解析的外部符号 "public: bool __cdecl FTexturePlatformData::IsAsyncWorkComplete(void)const " (?IsAsyncWorkComplete@FTexturePlatformData@@QEBA_NXZ),函数 "public: virtual class FTextureResource * __cdecl UTexture2DArrayEx::CreateResource(void)" (?CreateResource@UTexture2DArrayEx@@UEAAPEAVFTextureResource@@XZ) 中引用了该符号
11>Texture2DArrayEx.cpp.obj: Error LNK2019 : 无法解析的外部符号 "public: void __cdecl FTexturePlatformData::FinishCache(void)" (?FinishCache@FTexturePlatformData@@QEAAXXZ),函数 "public: virtual class FTextureResource * __cdecl UTexture2DArrayEx::CreateResource(void)" (?CreateResource@UTexture2DArrayEx@@UEAAPEAVFTextureResource@@XZ) 中引用了该符号
11>Texture2DArrayEx.cpp.obj: Error LNK2019 : 无法解析的外部符号 "public: void __cdecl UTexture::CachePlatformData(bool,bool,bool,class ITextureCompressorModule *)" (?CachePlatformData@UTexture@@QEAAX_N00PEAVITextureCompressorModule@@@Z),函数 "public: virtual void __cdecl UTexture2DArrayEx::UpdateResource(void)" (?UpdateResource@UTexture2DArrayEx@@UEAAXXZ) 中引用了该符号
11>Texture2DArrayEx.cpp.obj: Error LNK2019 : 无法解析的外部符号 "protected: struct FStreamableRenderResourceState __cdecl UTexture::GetResourcePostInitState(struct FTexturePlatformData const *,bool,int,int,bool)const " (?GetResourcePostInitState@UTexture@@IEBA?AUFStreamableRenderResourceState@@PEBUFTexturePlatformData@@_NHH1@Z),函数 "public: virtual class FTextureResource * __cdecl UTexture2DArrayEx::CreateResource(void)" (?CreateResource@UTexture2DArrayEx@@UEAAPEAVFTextureResource@@XZ) 中引用了该符号
11>Texture2DArrayResourceEx.cpp.obj: Error LNK2019 : 无法解析的外部符号 "public: __cdecl FStreamableTextureResource::FStreamableTextureResource(class UTexture *,struct FTexturePlatformData const *,struct FStreamableRenderResourceState const &,bool)" (??0FStreamableTextureResource@@QEAA@PEAVUTexture@@PEBUFTexturePlatformData@@AEBUFStreamableRenderResourceState@@_N@Z),函数 "public: __cdecl FTexture2DArrayResourceEx::FTexture2DArrayResourceEx(class UTexture2DArrayEx *,struct FStreamableRenderResourceState const &)" (??0FTexture2DArrayResourceEx@@QEAA@PEAVUTexture2DArrayEx@@AEBUFStreamableRenderResourceState@@@Z) 中引用了该符号
11>Texture2DArrayResourceEx.cpp.obj: Error LNK2019 : 无法解析的外部符号 "public: virtual void __cdecl FStreamableTextureResource::InitRHI(class FRHICommandListBase &)" (?InitRHI@FStreamableTextureResource@@UEAAXAEAVFRHICommandListBase@@@Z),函数 "public: virtual void __cdecl FTexture2DArrayResourceEx::InitRHI(class FRHICommandListBase &)" (?InitRHI@FTexture2DArrayResourceEx@@UEAAXAEAVFRHICommandListBase@@@Z) 中引用了该符号
11>Texture2DArrayResourceEx.cpp.obj: Error LNK2001 : 无法解析的外部符号 "public: virtual void __cdecl FStreamableTextureResource::ReleaseRHI(void)" (?ReleaseRHI@FStreamableTextureResource@@UEAAXXZ)
11>Texture2DArrayResourceEx.cpp.obj: Error LNK2019 : 无法解析的外部符号 "public: class TArrayView<struct FTexture2DMipMap const *,int> __cdecl FStreamableTextureResource::GetPlatformMipsView(void)const " (?GetPlatformMipsView@FStreamableTextureResource@@QEBA?AV?$TArrayView@PEBUFTexture2DMipMap@@H@@XZ),函数 "protected: virtual void __cdecl FTexture2DArrayResourceEx::CreateTexture(void)" (?CreateTexture@FTexture2DArrayResourceEx@@MEAAXXZ) 中引用了该符号
11>Texture2DArrayResourceEx.cpp.obj: Error LNK2019 : 无法解析的外部符号 "public: bool __cdecl UTexture2DArrayEx::GetMipData(int,class TArray<class FUniqueBuffer,class TSizedInlineAllocator<15,32,class TSizedDefaultAllocator<32> > > &)" (?GetMipData@UTexture2DArrayEx@@QEAA_NHAEAV?$TArray@VFUniqueBuffer@@V?$TSizedInlineAllocator@$0P@$0CA@V?$TSizedDefaultAllocator@$0CA@@@@@@@@Z),函数 "public: __cdecl FTexture2DArrayResourceEx::FTexture2DArrayResourceEx(class UTexture2DArrayEx *,struct FStreamableRenderResourceState const &)" (??0FTexture2DArrayResourceEx@@QEAA@PEAVUTexture2DArrayEx@@AEBUFStreamableRenderResourceState@@@Z) 中引用了该符号
11>UnrealEditor-SkeletalMesh2DStarter.dll: Error LNK1120 : 10 个无法解析的外部命令