{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/unreal-plugin-development/",
  "atlas": "https://www.pystone.net/?node=unreal-plugin-development#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/unreal-plugin-development.md",
  "context": "https://www.pystone.net/notes/unreal-plugin-development.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:unreal-plugin-development",
  "slug": "unreal-plugin-development",
  "title": "Unreal插件开发",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "Unreal插件开发",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "a0ecb1ce7fc5cf4d2c83201406ebc6f7b7a6ce9cdcf2930285f1ad3b9d2e53fa",
  "assets": [],
  "headings": [
    {
      "depth": 1,
      "text": "Unreal插件开发",
      "anchor": "unreal插件开发",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#unreal%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91"
    },
    {
      "depth": 2,
      "text": "目录结构",
      "anchor": "目录结构",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84"
    },
    {
      "depth": 3,
      "text": "Plugin Descriptor Files",
      "anchor": "plugin-descriptor-files",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#plugin-descriptor-files"
    },
    {
      "depth": 2,
      "text": "操作方法",
      "anchor": "操作方法",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#%E6%93%8D%E4%BD%9C%E6%96%B9%E6%B3%95"
    },
    {
      "depth": 3,
      "text": "打包发布",
      "anchor": "打包发布",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#%E6%89%93%E5%8C%85%E5%8F%91%E5%B8%83"
    },
    {
      "depth": 2,
      "text": "插件编译执行过程",
      "anchor": "插件编译执行过程",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#%E6%8F%92%E4%BB%B6%E7%BC%96%E8%AF%91%E6%89%A7%E8%A1%8C%E8%BF%87%E7%A8%8B"
    },
    {
      "depth": 2,
      "text": "编辑器拓展开发接口",
      "anchor": "编辑器拓展开发接口",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#%E7%BC%96%E8%BE%91%E5%99%A8%E6%8B%93%E5%B1%95%E5%BC%80%E5%8F%91%E6%8E%A5%E5%8F%A3"
    },
    {
      "depth": 2,
      "text": "其他技巧",
      "anchor": "其他技巧",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#%E5%85%B6%E4%BB%96%E6%8A%80%E5%B7%A7"
    },
    {
      "depth": 3,
      "text": "Include",
      "anchor": "include",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#include"
    },
    {
      "depth": 4,
      "text": "Include public",
      "anchor": "include-public",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#include-public"
    },
    {
      "depth": 4,
      "text": "Include private",
      "anchor": "include-private",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#include-private"
    },
    {
      "depth": 3,
      "text": "添加第三方依赖库",
      "anchor": "添加第三方依赖库",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#%E6%B7%BB%E5%8A%A0%E7%AC%AC%E4%B8%89%E6%96%B9%E4%BE%9D%E8%B5%96%E5%BA%93"
    },
    {
      "depth": 4,
      "text": "链接错误的解决方法",
      "anchor": "链接错误的解决方法",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#%E9%93%BE%E6%8E%A5%E9%94%99%E8%AF%AF%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95"
    },
    {
      "depth": 3,
      "text": "访问private或protected的UPROPERTY",
      "anchor": "访问private或protected的uproperty",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#%E8%AE%BF%E9%97%AEprivate%E6%88%96protected%E7%9A%84uproperty"
    },
    {
      "depth": 2,
      "text": "Build.cs",
      "anchor": "buildcs",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#buildcs"
    },
    {
      "depth": 2,
      "text": "Ref",
      "anchor": "ref",
      "citation": "https://www.pystone.net/notes/unreal-plugin-development/#ref"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "Unreal中的“Unreal插件开发”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#unreal"
    }
  ],
  "contentMarkdown": "# Unreal插件开发\n\n﻿# Unreal插件开发\n\n> 创建时间：2022/3/4 18:40\n\n* 目录结构\n    * Plugin Descriptor Files\n  * 操作方法\n    * 打包发布\n  * 插件编译执行过程\n  * 编辑器拓展开发接口\n  * 其他技巧\n    * Include\n      * Include public\n      * Include private\n    * 添加第三方依赖库\n      * 链接错误的解决方法\n    * 访问private或protected的UPROPERTY\n  * Build.cs\n  * Ref\n\n## 目录结构\n\nEngine /[UE4 Root]/Engine/Plugins/[Plugin Name]/\n\nGame /[Project Root]/Plugins/[Plugin Name]/\n(will be detected and loaded at Engine or Editor start-up time)\n\nPublic/Classes的父目录名就是module名\n\n### Plugin Descriptor Files\n\nPlugin descriptor Files: `.uplugin`\nAPI: https://docs.unrealengine.com/4.27/en-US/API/Runtime/Projects/FPluginDescriptor/\n\nCategory：类目名即在插件浏览器中所属的类目。\nInstalled：默认启用或禁用状态，在插件浏览器中可以控制加载卸载插件模块。\nModules：描述模块名、运行类型、加载时机、支持平台等信息。\nType：Runtime，RuntimeNoCommandlet，Developer，Editor，EditorNoCommandlet，Program。\nLoadingPhase：Default，PreDefault，PostConfigInit，PostConfigInit。\nWhitelistPlatforms：支持的平台\nBlacklistPlatforms：不支持的平台\n\n## 操作方法\n\nunreal的理念是开发工作都是在工程目录进行，包括插件开发\n\n### 打包发布\n\nhttps://blog.csdn.net/jxyb2012/article/details/88839224\n\n```xml\npublic class AGenericClass&lt;T&gt; where T : IComparable&lt;T&gt; { }\n\n```\n\n## 插件编译执行过程\n\nPlugins will automatically be compiled by UBT when compiling your game project.\n\n```xml\npublic class AGenericClass&lt;T&gt; where T : IComparable&lt;T&gt; { }\n\n```\n\n每个独立模块都有一个类继承自 IModuleInterface，重写了插件加载卸载的方法。\n\n.uplugin文件中Modules下的LoadingPhase字段说明了模块加载的时机，当满足这个时机时此模块StartupModule函数将被调用。此插件的功能入口就是从这里开始。当程序关闭或主动调用ShutdownModule函数时，模块将被卸载。\n\n## 编辑器拓展开发接口\n\nLevelEditorModule.GetToolBarExtensibilityManager()可以拓展关卡编辑器的工具栏，GetMenuExtensibilityManager()可以拓展菜单栏。\nGEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OnAssetOpenedInEditor()，可以监听UE中，任意编辑器打开的事件。\nFCoreUObjectDelegates::OnObjectPropertyChanged可以监听任意Object，任意属性的变化事件。\n\n## 其他技巧\n\n### Include\n\n> unreal中所有头文件都可以include。只是ue建议只include public目录或Classes的头文件，不建议include private目录的。\n\n#### Include public\n\n在XXX.Build.cs文件中添加依赖Module：PublicDependencyModuleNames.AddRange\n然后在某个源码文件，直接include。（从Public/Classes开始算路径）\n\n#### Include private\n\n在当前插件模块的build.cs文件中添加Private目录:\n\n```xml\npublic class AGenericClass&lt;T&gt; where T : IComparable&lt;T&gt; { }\n\n```\n```xml\npublic class AGenericClass&lt;T&gt; where T : IComparable&lt;T&gt; { }\n\n```\n\n### 添加第三方依赖库\n\nPublicIncludePaths.Add(zlibPath + “include” + platform); //把（.h）头文件路径引入。\nPublicLibraryPaths.Add(zlibPath + “lib” + platform); //把（.lib）库文件路径引入。\nPublicAdditionalLibraries.Add(“zlibstatic.lib”); //把（.lib）库文件引入。\n\nhttps://blog.csdn.net/jxyb2012/article/details/88839224\n\n#### 链接错误的解决方法\n\n  1. 确保：把所属module添加到PublicDependencyModuleNames中\n  2. 确保：如果缺失的函数or类是某个插件中的，需要标识为API，在函数前加入对应API宏。\n\n> 例如module名为SamplePlg，则API宏为：SAMPLEPLG_API\n\n### 访问private或protected的UPROPERTY\n\n```xml\npublic class AGenericClass&lt;T&gt; where T : IComparable&lt;T&gt; { }\n\n```\n```xml\npublic class AGenericClass&lt;T&gt; where T : IComparable&lt;T&gt; { }\n\n```\n\n## Build.cs\n\n配置文件属性详细说明：https://blog.csdn.net/jxyb2012/article/details/88839224\n\n```xml\npublic class AGenericClass&lt;T&gt; where T : IComparable&lt;T&gt; { }\n\n```\n\n## Ref\n\nhttps://www.jianshu.com/p/ec0ae889f417\nhttps://www.jianshu.com/p/49684c1b6011\nhttps://gameinstitute.qq.com/community/detail/121298\n"
}
