UE4 Editor Plugin UI
key | value |
---|
Module | DesktopPlatform | Header | /Engine/Source/Developer/DesktopPlatform/Public/IDesktopPlatform.h | Include | #include "IDesktopPlatform.h" |
Choose Local Folder to save
选择本地硬盘目录:
#include "IDesktopPlatform.h
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
FString DefaultLocation(FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_IMPORT));
FString Path = DefaultLocation;
bool bOpened = false;
if (DesktopPlatform)
{
bOpened = DesktopPlatform->OpenDirectoryDialog(
FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr),
TEXT("Choose folder to save"),
DefaultLocation,
Path
);
if (bOpened)
Path += "/";
}
Choose Content Folder
选择 UE4 project content 目录:
static FString Path = "/Game/";
TSharedRef<SDlgPickPath> PickContentPathDlg =
SNew(SDlgPickPath)
.Title(LOCTEXT("ChooseImportRootContentPath", "Choose Location for importing the H3D content"))
.DefaultPath(FText::FromString(Path));
if (PickContentPathDlg->ShowModal() == EAppReturnType::Cancel)
{
return;
}
Path = PickContentPathDlg->GetPath().ToString() + "/";
Open & Save File Dialog
打开本地文件和保存为本地文件对话框。
#include "IDesktopPlatform.h"
namespace FileDialogHelpers
{
bool SaveFile(const FString& Title, const FString& FileTypes, FString& InOutLastPath, const FString& DefaultFile, FString& OutFilename)
{
OutFilename = FString();
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bFileChosen = false;
TArray<FString> OutFilenames;
if (DesktopPlatform)
{
bFileChosen = DesktopPlatform->SaveFileDialog(
FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr),
Title,
InOutLastPath,
DefaultFile,
FileTypes,
EFileDialogFlags::None,
OutFilenames
);
}
bFileChosen = (OutFilenames.Num() > 0);
if (bFileChosen)
{
InOutLastPath = OutFilenames[0];
OutFilename = OutFilenames[0];
}
return bFileChosen;
}
bool OpenFiles(const FString& Title, const FString& FileTypes, FString& InOutLastPath, EFileDialogFlags::Type DialogMode, TArray<FString>& OutOpenFilenames)
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bOpened = false;
if (DesktopPlatform)
{
bOpened = DesktopPlatform->OpenFileDialog(
FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr),
Title,
InOutLastPath,
TEXT(""),
FileTypes,
DialogMode,
OutOpenFilenames
);
}
bOpened = (OutOpenFilenames.Num() > 0);
if (bOpened)
{
InOutLastPath = OutOpenFilenames[0];
}
return bOpened;
}
}
Message Dialog
#include "Misc/MessageDialog.h"
#define LOCTEXT_NAMESPACE "FH3DEditorModule"
FText DialogText = LOCTEXT("PluginDialogText", "Next please choose folder to save......");
FText DialogTitle = LOCTEXT("PluginDialogTitle", "Choose save folder");
FMessageDialog::Open(EAppMsgType::Ok, DialogText,&DialogTitle);
参考
- UE4 Editor Plugin UI
|