【问题标题】:UE4 Is there a way to include another file/class from Build.cs or Target.csUE4 有没有办法从 Build.cs 或 Target.cs 中包含另一个文件/类
【发布时间】:2021-02-12 02:47:21
【问题描述】:

我想为 Unreal-Engine 4 插件构建一个通用的 cmake 库导入器。我想创建另一个类来处理它并用于多个插件。我如何在插件 Build/Target.cs 文件中包含这个新类? (https://github.com/caseymcc/UE4CMake)

【问题讨论】:

    标签: c# unreal-engine4


    【解决方案1】:

    我确实发现您可以将所需的代码放入一个空插件中:

    public class BuildSource : ModuleRules
    {
        public BuildSource(ReadOnlyTargetRules Target) : base(Target)
        {
        }
        ...
        //what ever code you want to include in your builds
        ...
    }
    

    然后使用您的 uproject/uplugin 文件添加插件:

    {
        "FileVersion": 3,
        "EngineAssociation": "4.25",
        ...
        "Plugins": [
            {
                "Name": "BuildSource",
                "Enabled": true
            }
        ]
    }
    

    这将强制将BuildSource 中的代码编译为程序集并包含到您的项目中(无需导入)。如果您也在使用编辑器,您可能需要构建一个继承自 IModuleInterface 的空类以使其正确链接。确保调用 IMPLEMENT_MODULE(FBuildSourceEditorModule, BuildSource) 生成模块。

    我目前正在将它用于上述代码 (https://github.com/caseymcc/UE4CMake)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-29
      • 2015-06-14
      • 2023-03-08
      • 2013-05-09
      • 1970-01-01
      • 2019-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多