zoukankan      html  css  js  c++  java
  • UE4添加模块

    添加模块在这篇文章里已经有详细的描述了:

    https://orfeasel.com/creating-custom-modules/

    但是这篇文章中少写了一个步骤:

    最后要在

      <工程名>Editor.Target.cs

    以及

      <工程名>.Target.cs

    中做一点修改:

    ExtraModuleNames.AddRange( new string[] { ... } ); 

    这里也要加入新的模块名称字符串。在4.21中实际测试发现只有这样才能正常编译。

    下面举一例子,给一个名称为Test的工程添加一个叫做Ken的模块。

    Ken.h:

    #pragma once
    #include "CoreMinimal.h"
    #include "ModuleManager.h"
    class FKen:public IModuleInterface
    {
        public:
        /** IModuleInterface implementation */
        virtual void StartupModule() override;
        virtual void ShutdownModule() override;
    };

    Ken.cpp:

    #include "Ken.h"
    #include "Modules/ModuleManager.h"
    #define LOCTEXT_NAMESPACE "FKen"
    void FKen::StartupModule()
    {    
    UE_LOG(LogTemp, Warning, TEXT("KEN MODULE Start"));
    }
    void FKen::ShutdownModule()
    {
        UE_LOG(LogTemp, Warning, TEXT("KEN MODULE End"));
    }
    IMPLEMENT_MODULE(FKen, Ken)
    #undef LOCTEXT_NAMESPACE

    Ken.Build.cs文件:

    // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
    using UnrealBuildTool;
    public class Ken : ModuleRules
    {
        public Ken(ReadOnlyTargetRules Target) : base(Target)
        {
            PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;    
            PublicIncludePaths.AddRange(
                new string[] {
                    // ... add public include paths required here ...
                }
                );    
            PrivateIncludePaths.AddRange(
                new string[] {
                    // ... add other private include paths required here ...
                }
                );
            PublicDependencyModuleNames.AddRange(
                new string[]
                {
                    "Core",
    
                    // ... add other public dependencies that you statically link with here ...
                }
                );
            PrivateDependencyModuleNames.AddRange(
                new string[]
                {
                    "Test",
                    "Projects",
                    "InputCore",
                    "UnrealEd",
                    "LevelEditor",
                    "CoreUObject",
                    "Engine",
                    // ... add private dependencies that you statically link with here ...    
                }
                );
            DynamicallyLoadedModuleNames.AddRange(
                new string[]
                {
                    // ... add any modules that your module loads dynamically here ...
                }
                );
        }
    }

    Test.Target.cs文件:

    using UnrealBuildTool;
    using System.Collections.Generic;
    
    public class TestTarget : TargetRules
    {
        public TestTarget(TargetInfo Target) : base(Target)
        {
            Type = TargetType.Game;
    
            ExtraModuleNames.AddRange( new string[] { "Test","Ken" } );
        }
    }

    TestEditor.Target.cs文件:

    using UnrealBuildTool;
    using System.Collections.Generic;
    
    public class TestEditorTarget : TargetRules
    {
        public TestEditorTarget(TargetInfo Target) : base(Target)
        {
            Type = TargetType.Editor;
    
            ExtraModuleNames.AddRange( new string[] { "Test","Ken" } );
        }
    }

    请使用手机"扫一扫"x

  • 相关阅读:
    判断操作系统
    Oracle之初体验
    判断PDF文件是否相同(通过二进制流判断)
    jQuery基础 html+css3+jquery 点击按钮切换内容
    Jquery基础,点击事件click,鼠标移入事件mouseover。通过事件改变DOM结构
    Jquery教学基础,简单的淡入淡出,隐藏显示,改变CSS等
    Vuex的高级使用及localStorage
    Vuex实现数据共享
    Vue项目代码结构简单介绍
    Vue项目环境准备
  • 原文地址:https://www.cnblogs.com/AnKen/p/10654600.html
Copyright © 2011-2022 走看看