Hi Guys
I am working with a UE4 plugins,I got a problem,I cant create SListView correctly and I
m sure the problem is about the “.OnGenerateRow” function,when I built the project,error shows:
1>------ Build started: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
2>------ Build started: Project: RnD_Edit, Configuration: Development_Editor x64 ------
2> Compiling game modules for hot reload
2> Performing full C++ include scan (no include cache file)
2> Performing 2 actions (18 in parallel)
2> Module.DownloadAssets.cpp
2>c:\program files (x86)\epic games\4.12\engine\source\runtime\core\public\delegates\DelegateSignatureImpl_Variadics.inl(181): error C2039: 'AsShared': is not a member of 'FDownloadAssetsModule'
2> D:\Unreal Projects\RnD_Edit\Plugins\DownloadAssets\Source\DownloadAssets\Public\DownloadAssets.h(27): note: see declaration of 'FDownloadAssetsModule'
2> C:\Program Files (x86)\Epic Games\4.12\Engine\Source\Runtime\Slate\Public\Widgets\Views\SListView.h(65): note: see reference to function template instantiation 'TBaseDelegate<TSharedRef<ITableRow,0>,ArgumentType,const TSharedRef<STableViewBase,0> &> TBaseDelegate<TSharedRef<ITableRow,0>,ArgumentType,const TSharedRef<STableViewBase,0> &>::CreateSP<UserClass,>(UserClass *,TSharedRef<ITableRow,0> (__cdecl FDownloadAssetsModule::* )(ArgumentType,const TSharedRef<STableViewBase,0> &))' being compiled
2> with
2> [
2> ArgumentType=TSharedPtr<FInfoList,0>,
2> UserClass=FDownloadAssetsModule
2> ]
2> C:\Program Files (x86)\Epic Games\4.12\Engine\Source\Runtime\Slate\Public\Widgets\Views\SListView.h(65): note: see reference to function template instantiation 'TBaseDelegate<TSharedRef<ITableRow,0>,ArgumentType,const TSharedRef<STableViewBase,0> &> TBaseDelegate<TSharedRef<ITableRow,0>,ArgumentType,const TSharedRef<STableViewBase,0> &>::CreateSP<UserClass,>(UserClass *,TSharedRef<ITableRow,0> (__cdecl FDownloadAssetsModule::* )(ArgumentType,const TSharedRef<STableViewBase,0> &))' being compiled
2> with
2> [
2> ArgumentType=TSharedPtr<FInfoList,0>,
2> UserClass=FDownloadAssetsModule
2> ]
2> D:\Unreal Projects\RnD_Edit\Plugins\DownloadAssets\Source\DownloadAssets\Private\DownloadAssets.cpp(115): note: see reference to function template instantiation 'SListView<TSharedPtr<FInfoList,0>>::FArguments &SListView<TSharedPtr<FInfoList,0>>::FArguments::OnGenerateRow<FDownloadAssetsModule>(UserClass *,TSharedRef<ITableRow,0> (__cdecl FDownloadAssetsModule::* )(ArgumentType,const TSharedRef<STableViewBase,0> &))' being compiled
2> with
2> [
2> UserClass=FDownloadAssetsModule,
2> ArgumentType=TSharedPtr<FInfoList,0>
2> ]
2> D:\Unreal Projects\RnD_Edit\Plugins\DownloadAssets\Source\DownloadAssets\Private\DownloadAssets.cpp(117): note: see reference to function template instantiation 'SListView<TSharedPtr<FInfoList,0>>::FArguments &SListView<TSharedPtr<FInfoList,0>>::FArguments::OnGenerateRow<FDownloadAssetsModule>(UserClass *,TSharedRef<ITableRow,0> (__cdecl FDownloadAssetsModule::* )(ArgumentType,const TSharedRef<STableViewBase,0> &))' being compiled
2> with
2> [
2> UserClass=FDownloadAssetsModule,
2> ArgumentType=TSharedPtr<FInfoList,0>
2> ]
2>ERROR : UBT error : Failed to produce item: D:\Unreal Projects\RnD_Edit\Plugins\DownloadAssets\Binaries\Win64\UE4Editor-DownloadAssets-7060.dll
2> Total build time: 47.49 seconds
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3075: The command ""C:\Program Files (x86)\Epic Games\4.12\Engine\Build\BatchFiles\Build.bat" RnD_EditEditor Win64 Development "D:\Unreal Projects\RnD_Edit\RnD_Edit.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
this is the header:
#pragma once
#include "ModuleManager.h"
#include <windows.h>
#include <iostream>
#include <algorithm>
#include <string.h>
class FToolBarBuilder;
class FMenuBuilder;
struct FInfoList
{
/** Name of this template in the GUI */
FText Name;
/** Constructor */
FInfoList(FText InName):Name(InName)
{
}
};
class FDownloadAssetsModule : public IModuleInterface
{
public:
/**List Argument*/
TArray< TSharedPtr<FInfoList> > ElementList();
TSharedRef<ITableRow> OnGenerateWidgetForList(TSharedPtr<FInfoList> Item, const TSharedRef<STableViewBase>& OwnerTable);
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
/** This function will be bound to Command. */
void PluginButtonClicked();
private:
void AddToolbarExtension(FToolBarBuilder& Builder);
void AddMenuExtension(FMenuBuilder& Builder);
private:
TSharedPtr<class FUICommandList> PluginCommands;
TSharedRef<SWindow> ConstructWindowElement();
};
and This is the cpp file:
#include "DownloadAssetsPrivatePCH.h"
#include "SlateBasics.h"
#include "SlateExtras.h"
#include "DownloadAssetsStyle.h"
#include "DownloadAssetsCommands.h"
#include "LevelEditor.h"
static const FName DownloadAssetsTabName("DownloadAssets");
#define LOCTEXT_NAMESPACE "FDownloadAssetsModule"
void FDownloadAssetsModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
FDownloadAssetsStyle::Initialize();
FDownloadAssetsStyle::ReloadTextures();
FDownloadAssetsCommands::Register();
PluginCommands = MakeShareable(new FUICommandList);
PluginCommands->MapAction(
FDownloadAssetsCommands::Get().PluginAction,
FExecuteAction::CreateRaw(this, &FDownloadAssetsModule::PluginButtonClicked),
FCanExecuteAction());
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
{
TSharedPtr<FExtender> MenuExtender = MakeShareable(new FExtender());
MenuExtender->AddMenuExtension("WindowLayout", EExtensionHook::After, PluginCommands, FMenuExtensionDelegate::CreateRaw(this, &FDownloadAssetsModule::AddMenuExtension));
LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(MenuExtender);
}
{
TSharedPtr<FExtender> ToolbarExtender = MakeShareable(new FExtender);
ToolbarExtender->AddToolBarExtension("Settings", EExtensionHook::After, PluginCommands, FToolBarExtensionDelegate::CreateRaw(this, &FDownloadAssetsModule::AddToolbarExtension));
LevelEditorModule.GetToolBarExtensibilityManager()->AddExtender(ToolbarExtender);
}
}
void FDownloadAssetsModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
FDownloadAssetsStyle::Shutdown();
FDownloadAssetsCommands::Unregister();
}
TArray< TSharedPtr<FInfoList> > FDownloadAssetsModule::ElementList()
{
TArray< TSharedPtr<FInfoList> > Items;
const FText Test001 = LOCTEXT("Test001", "Test001");
const FText Test002 = LOCTEXT("Test002", "Test002");
const FText Test003 = LOCTEXT("Test003", "Test003");
const FText Test004 = LOCTEXT("Test004", "Test004");
TSharedPtr<FInfoList> Value1 = MakeShareable(new FInfoList(Test001));
TSharedPtr<FInfoList> Value2 = MakeShareable(new FInfoList(Test002));
TSharedPtr<FInfoList> Value3 = MakeShareable(new FInfoList(Test003));
TSharedPtr<FInfoList> Value4 = MakeShareable(new FInfoList(Test004));
Items.Add(Value1);
Items.Add(Value2);
Items.Add(Value3);
Items.Add(Value4);
return Items;
}
TSharedRef<SWindow> FDownloadAssetsModule::ConstructWindowElement()
{
TArray< TSharedPtr<FInfoList> > Items = this->ElementList();
TSharedRef<SWindow> Window = SNew(SWindow)
.Title(LOCTEXT("WindowTitle", "Mili Pipeline Tools"))
.SizingRule(ESizingRule::Autosized)
.Content()
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.ShadowColorAndOpacity(FLinearColor::Black)
.ColorAndOpacity(FLinearColor::Red)
.ShadowOffset(FIntPoint(-1, 1))
.Font(FSlateFontInfo("Verdana", 16))
.Text(LOCTEXT("Title", "Mili Test"))
]
+SVerticalBox::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Center)
[
SNew(SListView< TSharedPtr<FInfoList> >)
.ItemHeight(24)
.ListItemsSource(&Items)
.OnGenerateRow(this,&FDownloadAssetsModule::OnGenerateWidgetForList)
]
];
return Window;
}
TSharedRef<ITableRow> FDownloadAssetsModule::OnGenerateWidgetForList(TSharedPtr<FInfoList> Item, const TSharedRef<STableViewBase>& OwnerTable)
{
const float PaddingAmount = 12;
return SNew(STableRow< TSharedRef<FInfoList> >, OwnerTable)
[
SNew(SBorder)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.AutoHeight()
.Padding(PaddingAmount)
[
SNew(STextBlock)
.Text(Item->Name)
]
]
];
}
void FDownloadAssetsModule::PluginButtonClicked()
{
// show the windows
TSharedPtr<SWindow> ParentWindow;
// Check if the main frame is loaded. When using the old main frame it may not be.
if (FModuleManager::Get().IsModuleLoaded("MainFrame"))
{
IMainFrameModule& MainFrame = FModuleManager::LoadModuleChecked<IMainFrameModule>("MainFrame");
ParentWindow = MainFrame.GetParentWindow();
}
TSharedRef<SWindow> NewWindow = FDownloadAssetsModule().ConstructWindowElement();
//FSlateApplication::Get().AddModalWindow(NewWindow, ParentWindow, false); Lock the Window!
FSlateApplication::Get().AddWindowAsNativeChild(NewWindow, ParentWindow.ToSharedRef(), true);
}
void FDownloadAssetsModule::AddMenuExtension(FMenuBuilder& Builder)
{
Builder.AddMenuEntry(FDownloadAssetsCommands::Get().PluginAction);
}
void FDownloadAssetsModule::AddToolbarExtension(FToolBarBuilder& Builder)
{
Builder.AddToolBarButton(FDownloadAssetsCommands::Get().PluginAction);
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FDownloadAssetsModule, DownloadAssets)
I will appreciate any idea you can give.