UE4 如何写插件
来源:互联网 发布:虹云网络 编辑:程序博客网 时间:2024/05/16 11:35
事先说明各个版本的插件写法还是有点区别的我的是基于4.15版本的。
第一种:普通的插件
然后添加一个CPP放在插件的Private下,命名为:插件名+PricatePCH.h文件 这里的插件名为Test,以下以Test为示例讲解:
包含Test的.h文件
#include "Test.h"在Test.cpp里
把#include “Test.h” 替换成#include "TestPrivatePCH.h" 这样一部分就好了
然后新建自己的代码.h放入Public文件夹里,.cpp放进Private里 这里以TestBPLibrary为例
接下来就和普通的Actor C++代码差不多写法了,只要记得在cpp里添加PCH.h就可以了
.h
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.#pragma once#include "Engine.h"#include "TestBPLibrary.generated.h"/* *Function library class.*Each function in it is expected to be static and represents blueprint node that can be called in any blueprint.**When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable.*BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins.*BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins.*DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu.*Its lets you name the node using characters not allowed in C++ function names.*CompactNodeTitle - the word(s) that appear on the node.*Keywords -the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu. *Good example is "Print String" node which you can find also by using keyword "log".*Category -the category your node will be under in the Blueprint drop-down menu.**For more info on custom blueprint nodes visit documentation:*https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation*/UCLASS()class UTestBPLibrary : public UBlueprintFunctionLibrary{GENERATED_UCLASS_BODY()UFUNCTION(BlueprintCallable, meta = (DisplayName = "Execute Sample function nimei ", Keywords = "Test sample test testing"), Category = "TestPlugins")static float TestSampleFunction(float Param);UFUNCTION(BlueprintCallable, Category = "TestPlugins") //测试staticint32 Ttest(int32 a);};.cpp
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.#include "TestPrivatePCH.h"#include "TestBPLibrary.h"UTestBPLibrary::UTestBPLibrary(const FObjectInitializer& ObjectInitializer): Super(ObjectInitializer){}float UTestBPLibrary::TestSampleFunction(float Param){return -1;}int32 UTestBPLibrary::Ttest(int32 a) //测试{return -1;}
第二种:基于Object的插件
手先找到引擎目录下例如:D:\Epic Games\UE_4.15\Engine\Plugins\Developer 下面的UObjectPlugin,复制整个文件夹到插件目录下,需要在插件Bulid.cs下"Engine"
然后老样子添加PCH.h文件
#include "IUObjectPlugin.h"#include "GameFramework/Actor.h"//这行看你要做什么Object 这里做的是Actor#include "Engine.h"#include "CoreUObject.h"把MyPluginObject.h的#include "CoreMinimal.h"注释掉
把IUObjectPlugin.h的#include "CoreMinimal.h"和"Modules/ModuleInterface.h"注释掉
把UObjectPlugin.cpp的全部注释掉并加上#include "UObjectPluginPrivatePCH.h"
把MyPluginObject.cpp加上#include "UObjectPluginPrivatePCH.h"和#include "ObjectTools.h"
下面同样添加自己的代码 这里我命名为ZZActor
.h
#pragma once#include "GameFramework/Actor.h"#include "ZZActor.generated.h"UCLASS()class AZZActor : public AActor{GENERATED_BODY()public:// Sets default values for this actor's propertiesAZZActor();UFUNCTION(BlueprintCallable, Category = "objectPlugins") //测试int32 testzz(int32 a);};.cpp
#include "UObjectPluginPrivatePCH.h"#include "ZZActor.h"AZZActor::AZZActor():Super(){}int32 AZZActor::testzz(int32 a) //测试{return -1;}
然后就可以在项目里新建蓝图看到了
PS(新版的插件)改成类似
public BBB(ReadOnlyTargetRules Target) : base(Target){PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;PublicIncludePaths.AddRange(new string[] {"BBB/Public"// ... add public include paths required here ...});}
阅读全文
3 0
- UE4 如何写插件
- [UE4]用Slate框架写UE4插件
- UE4插件
- 如何写恶意插件
- 如何写nopCommerce插件
- 如何写jquery插件
- 如何写jquery插件
- 如何写jQuery插件
- 如何写一个extjs插件
- jQuery 如何写插件 - 第一步
- jQuery 如何写插件 - 第一步
- 如何写一个jquery 插件
- ue4插件开发
- Ue4使用OpenCV插件
- ue4插件开发
- ue4插件开发
- UE4 扩展节点插件
- jQuery 如何写插件 - 第二步
- 编程第二十三、二十四天
- ==与equals()的区别
- PHP使用七牛云存储之图片的上传、下载、303重定向教程,CI框架实例
- 【三】、整合SpringMVC(基本配置和thymeleaf模板选择)
- 毕设论文
- UE4 如何写插件
- 编程第二十五、二十六天
- 1051. 复数乘法 (15) PAT
- 用R语言igraph库实现表自动关联
- 新闻客户端
- UICollectionView reloadData不走cellForRowAtIndexPath的问题
- URL标准概念
- 3224: Tyvj 1728 普通平衡树 P3369 【模板】普通平衡树(Treap/SBT)Treap
- LeetCode 119. Pascal's Triangle II