商用营销型网站建设,网站建设专员招聘,建筑网站设置工资单人换了怎么换,网络品牌推广ppt0#xff0c;前言 我看的是 技术宅阿棍儿 的视频#xff0c;B站有。 系列视频#xff1a;从代码引用插件_哔哩哔哩_bilibili 看不懂#xff0c;只能边查资料边看#xff0c;讲的顺序有点乱 1#xff0c;根据视频提示创建第三方插件 注意#xff1a;如果只有空白插件的情…0前言 我看的是 技术宅阿棍儿 的视频B站有。 系列视频从代码引用插件_哔哩哔哩_bilibili 看不懂只能边查资料边看讲的顺序有点乱 1根据视频提示创建第三方插件 注意如果只有空白插件的情况需要你创建一个C类就能够看到很多插件类型了 具体看着Creating New Plugins - non-content only - missing templates? - #3 by JollyTarkaVFX - C - Epic Developer Community Forums 将这个插件放在了ue引擎或者选择放在项目下面建议后者 2创建游戏模式 可以参考以下文章很简单就看前面的两步就OK: 以下过程会让你的UE不断重启 UE4开发三创建游戏模式、角色、控制器_mergerly的博客-CSDN博客_ue4玩家控制器游戏模式作用 然后你会拥有如下的文件结构 新建工程下的目录 介绍一下文件结构和调用关系是 第三方插件调用第三方库 3创建第三方插件的类
1按照图上的步骤来 最后打开vs重启就行 4第三方插件的代码修改
1修改ThirdLibInvoker类的代码 ThirdLibInvoker.h class MYTHIRDPLUGIN2_API UThirdLibInvoker : public UObject
{GENERATED_BODY()void* ExampleLibraryHandle;public:~UThirdLibInvoker();void InvokeLib();
}; ThirdLibInvoker.cpp 这里其实是将MyThirdPlugin2.cpp的代码拷贝过来憋看到就害怕了~ // Fill out your copyright notice in the Description page of Project Settings.#include ThirdLibInvoker.h
#include Core.h
#include Modules/ModuleManager.h
#include Interfaces/IPluginManager.h
#include MyThirdPlugin2Library/ExampleLibrary.hUThirdLibInvoker::~UThirdLibInvoker()
{FPlatformProcess::FreeDllHandle(ExampleLibraryHandle);ExampleLibraryHandle nullptr;
}void UThirdLibInvoker::InvokeLib()
{if (ExampleLibraryHandle nullptr){// Get the base directory of this pluginFString BaseDir IPluginManager::Get().FindPlugin(MyThirdPlugin2)-GetBaseDir();// Add on the relative location of the third party dll and load itFString LibraryPath;
#if PLATFORM_WINDOWSLibraryPath FPaths::Combine(*BaseDir, TEXT(Binaries/ThirdParty/MyThirdPlugin2Library/Win64/ExampleLibrary.dll));
#elif PLATFORM_MACLibraryPath FPaths::Combine(*BaseDir, TEXT(Source/ThirdParty/MyThirdPlugin2Library/Mac/Release/libExampleLibrary.dylib));
#elif PLATFORM_LINUXLibraryPath FPaths::Combine(*BaseDir, TEXT(Binaries/ThirdParty/MyThirdPlugin2Library/Linux/x86_64-unknown-linux-gnu/libExampleLibrary.so));
#endif // PLATFORM_WINDOWSExampleLibraryHandle !LibraryPath.IsEmpty() ? FPlatformProcess::GetDllHandle(*LibraryPath) : nullptr;if (ExampleLibraryHandle){// Call the test function in the third party library that opens a message boxExampleLibraryFunction();}else{//FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT(ThirdPartyLibraryError, Failed to load example third party library));}}}2修改MyThirdPlugin2的代码 MyThirdPlugin2.h 删掉void * exemplexxxx具体啥名字忘记了 加上class UThirdLibInvoker * Lib; MyThirdPlugin2.cpp void FMyThirdPlugin2Module::StartupModule()
{// 将这些代码复制到ThirdLibInvoker.cpp里面去Lib NewObjectUThirdLibInvoker();Lib-InvokeLib();}
void FMyThirdPlugin2Module::ShutdownModule()
{//删掉这里面的代码
} 3MyThirdPlugin2.Build.cs修改 添加CoreUObject 5第三方库的代码修改 及其 编译方法
1ExampleLibrary.cpp代码修改 改一个你喜欢的弹窗吧~ EXAMPLELIBRARY_EXPORT void ExampleLibraryFunction()
{
#if defined _WIN32 || defined _WIN64MessageBox(NULL, TEXT(你成功调用了我* ^ *~), TEXT(Third Party Plugin), MB_OK);
#elseprintf(Loaded ExampleLibrary from Third Party Plugin sample);
#endif
} 2 编译方式 1VS新建一个工程叫MyThirdLibPluginLibrary我放在了这里UE4_PluginAndSlate\Plugins\MyThirdPlugin2\Source\ThirdParty\MyThirdPlugin2Library\ExampleLibrary\MyThirdLibPluginLibrary 2工程中添加ExampleLibrary.cpp, ExampleLibrary.h两个文件 3修改MyThirdLibPluginLibrary工程属性点击工程右键选择属性 找到这两个文件的路径修改输出目录为这两个文件的路径如下图 然后点击右上角配置管理器改为release 4将生成的dll拷贝到编辑器寻找的路径下面 我们可以看到ThirdLibInvoker.cpp代码里面是通过这句话来加载第三方库的编辑器只会朝这个路径下寻找ExampleLibrary.dll因此需要将新生成的ExampleLibrary.dll拷贝过去 LibraryPath FPaths::Combine(*BaseDir, TEXT(Binaries/ThirdParty/MyThirdPlugin2Library/Win64/ExampleLibrary.dll)); 4游戏模块的代码修改
1.cs代码统一修改 UE4_PluginAndSlate.Build.cs UE4_PluginAndSlate.Target.cs UE4_PluginAndSlateEditor.Target.cs 2MyGameModeBase MyGameModeBase.h 添加beginplay函数 class UE4_PLUGINANDSLATE_API AMyGameModeBase : public AGameModeBase
{GENERATED_BODY()
protected:virtual void BeginPlay() override;
};MyGameModeBase.cpp void AMyGameModeBase::BeginPlay()
{Super::BeginPlay();UThirdLibInvoker* Lib NewObjectUThirdLibInvoker();Lib-InvokeLib();
}5设置世界场景运行游戏 设置游戏模式并且运行 运行结果