原创文章,转载请注明出处。
**
** 1> 一个插件至少有一个模块 2>一般插件都是做底层做通用设计的,而模块做的负责的我理解为逻辑
ProjectName.Build.cs //主要管理的是链接, dll的链接
ProjectName.Target.cs //管理的是编译,加上才会编译你的Module, 如果你是runtime模块,放到这里
ProjectName.Editor.Target.cs //管理的是编译,加上才会编译你的Module, 如果你的是editor模块,那么好,放这里
关于.Build.cs中的一些介绍
PublicDependencyModuleNames.AddRange(new string[] {
"Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] {
});
PublicDependencyModuleNames 里面的所有模块都会被引用该模块的模块所继承使用,你就理解成public
PrivateDependencyModuleNames 与上面相反了,按private理解
1>我的SelectDialog插件,放置三个模块。如下图
2>在你的Plugin中加上你的模块引用,如下图
3>加上模块中的 StartupModule和ShutdownModule可以在模块初始化和模块卸载时增加你的业务逻辑,如下图
头文件.h
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "ISlateFileDialogModuleEx.h"
class FSlateFileDialogsStyle;
class FSlateFileDialogsModule : public ISlateFileDialogsModule
{
public:
// IModuleInterface interface
virtual void StartupModule() override;
virtual void ShutdownModule() override;
public:
//ISlateFileDialogModule interface
bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath,
const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray<FString>& OutFilenames, int32& OutFilterIndex);
bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath,
const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray<FString>& OutFilenames);
bool OpenDirectoryDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath,
FString& OutFoldername);
bool SaveFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath,
const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray<FString>& OutFilenames);
ISlateFileDialogsModule* Get();
FSlateFileDialogsStyle *GetFileDialogsStyle() {
return FileDialogStyle; }
private:
ISlateFileDialogsModule *SlateFileDialog;
FSlateFileDialogsStyle *FileDialogStyle;
};
实现.cpp
// Copyright Epic Games, Inc. All Rights Reserved.
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
#include "SlateFileDialogsEx.h"
#include "SlateFileDialogsStylesEx.h"
#include "SlateFileDlgWindowEx.h"
void FSlateFileDialogsModule::StartupModule()
{
SlateFileDialog = new FSlateFileDialogsModule();
FileDialogStyle = new FSlateFileDialogsStyle;
FileDialogStyle->Initialize();
}
void FSlateFileDialogsModule::ShutdownModule()
{
if (SlateFileDialog != NULL)
{
FileDialogStyle->Shutdown();
delete FileDialogStyle;
delete SlateFileDialog;
SlateFileDialog = NULL;
}
}
bool FSlateFileDialogsModule::OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath,
const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray<FString>& OutFilenames, int32& OutFilterIndex)
{
FSlateFileDlgWindow dialog(FileDialogStyle);
return dialog.OpenFileDialog(ParentWindowHandle, DialogTitle, DefaultPath, DefaultFile, FileTypes, Flags, OutFilenames, OutFilterIndex);
}
bool FSlateFileDialogsModule::OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath,
const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray<FString>& OutFilenames)
{
FSlateFileDlgWindow dialog(FileDialogStyle);
return dialog.OpenFileDialog(ParentWindowHandle, DialogTitle, DefaultPath, DefaultFile, FileTypes, Flags, OutFilenames);
}
bool FSlateFileDialogsModule::OpenDirectoryDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath,
FString& OutFoldername)
{
FSlateFileDlgWindow dialog(FileDialogStyle);
return dialog.OpenDirectoryDialog(ParentWindowHandle, DialogTitle, DefaultPath, OutFoldername);
}
bool FSlateFileDialogsModule::SaveFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath,
const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray<FString>& OutFilenames)
{
FSlateFileDlgWindow dialog(FileDialogStyle);
return dialog.SaveFileDialog(ParentWindowHandle, DialogTitle, DefaultPath, DefaultFile, FileTypes, Flags, OutFilenames);
}
ISlateFileDialogsModule* FSlateFileDialogsModule::Get()
{
return SlateFileDialog;
}
IMPLEMENT_MODULE(FSlateFileDialogsModule, SlateFileDialogsEx);
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/186104.html原文链接:https://javaforall.cn