首先,每个模块,包含插件内的模块在内,都要用IMPLEMENT_MODULE(类名, 模块名)的方式,模块名就是带.build.cs的第一个单词。
build.cs里就说了这个模块该怎么用,用c#编写。
打包中要考虑到target.cs,将工程中相应的模块打包进去
uproject就要连插件和模块一起写进去
比如
这里,CoreOne和CoreTwo是工程里的多模块,myplugin和otherM是插件里的多模块。废话不多说,上代码
以工程中的一个模块CoreOne为例
coreOne.h
#pragma once
#include “CoreMinimal.h”
#include “Modules/ModuleManager.h”
class FCoreOneModule : public FDefaultGameModuleImpl
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};
coreone.cpp
#include “CoreOne.h”
#include “Modules/ModuleManager.h”
#define LOCTEXT_NAMESPACE “CoreOne”
void FCoreOneModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
}
void FCoreOneModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FCoreOneModule, CoreOne);
coreone.build.cs
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class CoreOne : ModuleRules
{
public CoreOne(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUOb