隐式导入需要lib文件,dll文件,h文件

和传统c++不一样的是UE4不需要

#pragma comment(lib, "Dll2.lib")

而是需要在c#里面改东西

// Copyright Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.IO;

public class Chess : ModuleRules
{
	private string ModulePath
    {
        get
        {
			return ModuleDirectory;
        }
    }

	private string ThirdPartyPath
	{
		get
		{
			return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/Lib/"));
		}
	}

	public void LoadxxxLib()
	{
		PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Dll2.lib"));
		PublicDelayLoadDLLs.Add("Dll2.dll");
		RuntimeDependencies.Add(new RuntimeDependency(ThirdPartyPath + "Dll2.dll"));
		return;
	}

	public Chess(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
		
		PublicIncludePaths.AddRange(
			new string[] {
				// ... add public include paths required here ...
				Path.Combine(ThirdPartyPath),
			}
			);
				
		
		PrivateIncludePaths.AddRange(
			new string[] {
				// ... add other private include paths required here ...
				Path.Combine(ThirdPartyPath),
			}
			);
			
		
		PublicDependencyModuleNames.AddRange(
			new string[]
			{
				"Core",
				// ... add other public dependencies that you statically link with here ...
			}
			);
			
		
		PrivateDependencyModuleNames.AddRange(
			new string[]
			{
				"CoreUObject",
				"Engine",
				"Slate",
				"SlateCore",
				// ... add private dependencies that you statically link with here ...	
			}
			);
		
		
		DynamicallyLoadedModuleNames.AddRange(
			new string[]
			{
				// ... add any modules that your module loads dynamically here ...
			}
			);
		LoadxxxLib();
	}

}

用的时候注意路径

之后就可以使用头文件里面的类了

更多推荐