ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

UE4_Plugins模板Editor Standalone Window 初步理解

2021-05-06 02:02:51  阅读:423  来源: 互联网

标签:FButtomStyle Standalone FButtomCommands void Register MapAction Window Editor FB


一.

1.创建插件 Editor Standalone Window

 

 2.目录下会生成如下文件

 

 

分别为Buttom/ButtomCommands/ButtomStyle   Buttom.Build.cs 文件

3. 打开ButtomCommands.cpp

通过断点,观察 以下函数顺序

void FButtomCommands::RegisterCommands()
ButtomCommands.cpp

#include "ButtomCommands.h"

#define LOCTEXT_NAMESPACE "FButtomModule"
//断点位置
void FButtomCommands::RegisterCommands()
{
    UI_COMMAND(OpenPluginWindow, "Buttom", "Bring up Buttom window", EUserInterfaceActionType::Button, FInputGesture());
}

#undef LOCTEXT_NAMESPACE

 

如下图,会看到调用顺序为

 

调用位置1
void FButtomModule::StartupModule()
{
    // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
    
    FButtomStyle::Initialize();
    FButtomStyle::ReloadTextures();
    FButtomCommands::Register();
调用位置2 commands.h  void Register
template<typename CommandContextType>
class TCommands : public FBindingContext
{
public:
    
    /** Use this method to register commands. Usually done in StartupModule(). */
    FORCENOINLINE static void Register()
    {
        if ( !Instance.IsValid() )
        {
            
            TSharedRef<CommandContextType> NewInstance = MakeShareable( new CommandContextType() );
       Instance = NewInstance;
       NewInstance->RegisterCommands();

由此我们可见,通过实例化 Commands 然后调用
NewInstance->RegisterCommands()

 

二.CommandList

回到StartupModule中, FUICommandList主要为绑定一些命令 , 

 

void FButtomModule::StartupModule()
{
    // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
    
    FButtomStyle::Initialize();
    FButtomStyle::ReloadTextures();

    FButtomCommands::Register();
    
    PluginCommands = MakeShareable(new FUICommandList);

    PluginCommands->MapAction(
        FButtomCommands::Get().OpenPluginWindow,
        FExecuteAction::CreateRaw(this, &FButtomModule::PluginButtonClicked),
        FCanExecuteAction());

MapAction :将命令信息映射到由multibox或鼠标/键盘输入执行的一系列委托

贴一段MapAction :

void MapAction( const TSharedPtr< const FUICommandInfo > InUICommandInfo, FExecuteAction ExecuteAction, EUIActionRepeatMode RepeatMode = EUIActionRepeatMode::RepeatDisabled );

    /**
     * Maps a command info to a series of delegates that are executed by a multibox or mouse/keyboard input
     *
     * @param InUICommandInfo    The command info to map
     * @param ExecuteAction        The delegate to call when the command should be executed
     * @param CanExecuteAction    The delegate to call to see if the command can be executed
     * @param RepeatMode        Can this action can be repeated if the chord used to call it is held down?
     */

基本可以看到 InUICommandInfo :要映射的命令信息,ExecuteAction:什么时候应该执行命令

通过create_raw的方式:

 PluginCommands->MapAction(
        FButtomCommands::Get().OpenPluginWindow,
        FExecuteAction::CreateRaw(this, &FButtomModule::PluginButtonClicked),
        FCanExecuteAction());

找到 void FButtomModule::PluginButtonClicked() 

void FButtomModule::PluginButtonClicked()
{
    //FGlobalTabmanager::Get()->TryInvokeTab(ButtomTabName);
}

//可以进行一些自定义操作,我们想实现的功能

标签:FButtomStyle,Standalone,FButtomCommands,void,Register,MapAction,Window,Editor,FB
来源: https://www.cnblogs.com/zsymdbk/p/14720424.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有