联机版实现,先备份
This commit is contained in:
		
							
								
								
									
										104
									
								
								Tools/使用示例.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								Tools/使用示例.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,104 @@ | ||||
| # UE头文件解析工具使用示例 | ||||
|  | ||||
| ## 基本用法 | ||||
|  | ||||
| ### 扫描整个项目 | ||||
| ```bash | ||||
| python Tools/ue_header_parser.py Source/BusyRabbit/Public -o Content/Lua/@types | ||||
| ``` | ||||
|  | ||||
| ### 扫描特定目录 | ||||
| ```bash | ||||
| # 扫描Components目录 | ||||
| python Tools/ue_header_parser.py Source/BusyRabbit/Public/Components -o Content/Lua/@types | ||||
|  | ||||
| # 扫描Level目录 | ||||
| python Tools/ue_header_parser.py Source/BusyRabbit/Public/Level -o Content/Lua/@types | ||||
| ``` | ||||
|  | ||||
| ### 扫描单个文件 | ||||
| ```bash | ||||
| # 直接指定文件路径(需要先确保输出目录存在) | ||||
| python Tools/ue_header_parser.py Source/BusyRabbit/Public/Components/InventoryComponent.h -o Content/Lua/@types | ||||
| ``` | ||||
|  | ||||
| ## 生成结果示例 | ||||
|  | ||||
| ### 输入头文件 (InventoryComponent.h) | ||||
| ```cpp | ||||
| USTRUCT(BlueprintType) | ||||
| struct FInventoryGrid { | ||||
|     GENERATED_BODY() | ||||
| public: | ||||
|     UPROPERTY(BlueprintReadOnly, DisplayName = "物品ID") | ||||
|     int32 ItemID; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadWrite, DisplayName = "当前的数量") | ||||
|     int32 CurrentCount; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadWrite, DisplayName = "最大堆叠限制") | ||||
|     int32 MaxCount; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadWrite, DisplayName = "优先级") | ||||
|     int32 Priority; | ||||
| }; | ||||
|  | ||||
| UCLASS() | ||||
| class BUSYRABBIT_API UInventoryComponent : public ULuaActorComponent { | ||||
|     GENERATED_BODY() | ||||
| public: | ||||
|     UFUNCTION(BlueprintCallable) | ||||
|     bool IsCanContain(int32 ItemID, int32 Count); | ||||
|      | ||||
|     // ... 其他函数和属性 | ||||
| }; | ||||
| ``` | ||||
|  | ||||
| ### 输出注解文件 (InventoryComponent.d.lua) | ||||
| ```lua | ||||
| -- 自动生成的emmy-lua注解文件 | ||||
| -- 源文件: Source/BusyRabbit/Public/Components\InventoryComponent.h | ||||
|  | ||||
| ---@class FInventoryGrid | ||||
| ---@field ItemID integer | ||||
| ---@field CurrentCount integer | ||||
| ---@field MaxCount integer | ||||
| ---@field Priority integer | ||||
| local FInventoryGrid = {} | ||||
|  | ||||
| ---@class UInventoryComponent : ULuaActorComponent | ||||
| ---@field Capacity integer | ||||
| ---@field InventoryList table<any> | ||||
| ---@param ItemID integer | ||||
| ---@param Count integer | ||||
| ---@return boolean | ||||
| function UInventoryComponent:IsCanContain(ItemID, Count) end | ||||
|  | ||||
| -- ... 其他函数注解 | ||||
| ``` | ||||
|  | ||||
| ## 集成到开发流程 | ||||
|  | ||||
| ### 1. 定期生成注解 | ||||
| 建议在每次UE头文件更新后运行工具重新生成注解。 | ||||
|  | ||||
| ### 2. 版本控制 | ||||
| 将生成的`.d.lua`文件添加到版本控制中,方便团队共享。 | ||||
|  | ||||
| ### 3. IDE配置 | ||||
| 确保IDE(如VSCode)能够识别`Content/Lua/@types`目录中的注解文件。 | ||||
|  | ||||
| ## 注意事项 | ||||
|  | ||||
| 1. **类型映射**: 工具会自动将C++类型映射到Lua类型 | ||||
| 2. **模板类型**: 支持`TArray<FInventoryGrid>`等模板类型的解析 | ||||
| 3. **委托支持**: 自动生成委托类型的Call函数注解 | ||||
| 4. **错误处理**: 工具会跳过无法解析的文件并继续处理其他文件 | ||||
|  | ||||
| ## 故障排除 | ||||
|  | ||||
| 如果遇到问题,请检查: | ||||
| - 头文件语法是否正确 | ||||
| - UE宏格式是否符合标准 | ||||
| - 输出目录权限是否足够 | ||||
| - Python版本是否为3.6+ | ||||
		Reference in New Issue
	
	Block a user