• 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

  • 相关阅读:
    如何学习一门新技术
    linux atoi
    linux switch 跳转到 ”跳转至 case 标号“ 的错误
    from unittest import TestCase
    ensure that both new and old access_token values are available within five minutes, so that third-party services are smoothly transitioned.
    .BigInteger
    408
    Convert a string into an ArrayBuffer
    Optimal asymmetric encryption padding 最优非对称加密填充(OAEP)
    https://tools.ietf.org/html/rfc8017
  • 原文地址:https://www.cnblogs.com/AnKen/p/10654600.html
Copyright © 2020-2023  润新知