UE4 Editor Plugin UI
2021/11/16 23:11:38
本文主要是介绍UE4 Editor Plugin UI,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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 { /** * @param Title The title of the dialog * @param FileTypes Filter for which file types are accepted and should be shown * @param InOutLastPath Keep track of the last location from which the user attempted an import * @param DefaultFile Default file name to use for saving. * @param OutOpenFilenames The list of filenames that the user attempted to open * * @return true if the dialog opened successfully and the user accepted; false otherwise. */ 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) { // User successfully chose a file; remember the path for the next time the dialog opens. InOutLastPath = OutFilenames[0]; OutFilename = OutFilenames[0]; } return bFileChosen; } /** * @param Title The title of the dialog * @param FileTypes Filter for which file types are accepted and should be shown * @param InOutLastPath Keep track of the last location from which the user attempted an import * @param DialogMode Multiple items vs single item. * @param OutOpenFilenames The list of filenames that the user attempted to open * * @return true if the dialog opened successfully and the user accepted; false otherwise. */ 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) { // User successfully chose a file; remember the path for the next time the dialog opens. 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
这篇关于UE4 Editor Plugin UI的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-22项目:远程温湿度检测系统
- 2024-12-21《鸿蒙HarmonyOS应用开发从入门到精通(第2版)》简介
- 2024-12-21后台管理系统开发教程:新手入门全指南
- 2024-12-21后台开发教程:新手入门及实战指南
- 2024-12-21后台综合解决方案教程:新手入门指南
- 2024-12-21接口模块封装教程:新手必备指南
- 2024-12-21请求动作封装教程:新手必看指南
- 2024-12-21RBAC的权限教程:从入门到实践
- 2024-12-21登录鉴权实战:新手入门教程
- 2024-12-21动态权限实战入门指南