[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-af036753-cf5c-4e94-893a-27d63bc1ff5c":3,"$fpAYk5Gl3V1vmrZFrzeSdp1xY7Js4bXeTCLswE2S50iM":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"af036753-cf5c-4e94-893a-27d63bc1ff5c","unreal-engine-cpp-pro","Unreal Engine 5.x C++开发专家指南，涵盖UObject卫生、性能模式和最佳实践。","cat_coding_frontend","mod_coding","sickn33,coding","---\nname: unreal-engine-cpp-pro\ndescription: \"Expert guide for Unreal Engine 5.x C++ development, covering UObject hygiene, performance patterns, and best practices.\"\nrisk: safe\nsource: self\ndate_added: \"2026-02-27\"\n---\n\n# Unreal Engine C++ Pro\n\nThis skill provides expert-level guidelines for developing with Unreal Engine 5 using C++. It focuses on writing robust, performant, and standard-compliant code.\n\n## When to Use\nUse this skill when:\n- Developing C++ code for Unreal Engine 5.x projects\n- Writing Actors, Components, or UObject-derived classes\n- Optimizing performance-critical code in Unreal Engine\n- Debugging memory leaks or garbage collection issues\n- Implementing Blueprint-exposed functionality\n- Following Epic Games' coding standards and conventions\n- Working with Unreal's reflection system (UCLASS, USTRUCT, UFUNCTION)\n- Managing asset loading and soft references\n\nDo not use this skill when:\n- Working with Blueprint-only projects (no C++ code)\n- Developing for Unreal Engine versions prior to 5.x\n- Working on non-Unreal game engines\n- The task is unrelated to Unreal Engine development\n\n## Core Principles\n\n1.  **UObject & Garbage Collection**:\n    *   Always use `UPROPERTY()` for `UObject*` member variables to ensure they are tracked by the Garbage Collector (GC).\n    *   Use `TStrongObjectPtr\u003C>` if you need to keep a root reference outside of a UObject graph, but prefer `addToRoot()` generally.\n    *   Understand the `IsValid()` check vs `nullptr`. `IsValid()` handles pending kill state safely.\n\n2.  **Unreal Reflection System**:\n    *   Use `UCLASS()`, `USTRUCT()`, `UENUM()`, `UFUNCTION()` to expose types to the reflection system and Blueprints.\n    *   Minimize `BlueprintReadWrite` when possible; prefer `BlueprintReadOnly` for state that shouldn't be trampled by logic in UI\u002FLevel BPs.\n\n3.  **Performance First**:\n    *   **Tick**: Disable Ticking (`bCanEverTick = false`) by default. Only enable it if absolutely necessary. Prefer timers (`GetWorldTimerManager()`) or event-driven logic.\n    *   **Casting**: Avoid `Cast\u003CT>()` in hot loops. Cache references in `BeginPlay`.\n    *   **Structs vs Classes**: Use `F` structs for data-heavy, non-UObject types to reduce overhead.\n\n## Naming Conventions (Strict)\n\nFollow Epic Games' coding standard:\n\n*   **Templates**: Prefix with `T` (e.g., `TArray`, `TMap`).\n*   **UObject**: Prefix with `U` (e.g., `UCharacterMovementComponent`).\n*   **AActor**: Prefix with `A` (e.g., `AMyGameMode`).\n*   **SWidget**: Prefix with `S` (Slate widgets).\n*   **Structs**: Prefix with `F` (e.g., `FVector`).\n*   **Enums**: Prefix with `E` (e.g., `EWeaponState`).\n*   **Interfaces**: Prefix with `I` (e.g., `IInteractable`).\n*   **Booleans**: Prefix with `b` (e.g., `bIsDead`).\n\n## Common Patterns\n\n### 1. Robust Component Lookup\nAvoid `GetComponentByClass` in `Tick`. Do it in `PostInitializeComponents` or `BeginPlay`.\n\n```cpp\nvoid AMyCharacter::PostInitializeComponents() {\n    Super::PostInitializeComponents();\n    HealthComp = FindComponentByClass\u003CUHealthComponent>();\n    check(HealthComp); \u002F\u002F Fail hard in dev if missing\n}\n```\n\n### 2. Interface Implementation\nUse interfaces to decouple systems (e.g., Interaction system).\n\n```cpp\n\u002F\u002F Interface call check\nif (TargetActor->Implements\u003CUInteractable>()) {\n    IInteractable::Execute_OnInteract(TargetActor, this);\n}\n```\n\n### 3. Async Loading (Soft References)\nAvoid hard references (`UPROPERTY(EditDefaultsOnly) TSubclassOf\u003CAActor>`) for massive assets which force load orders. Use `TSoftClassPtr` or `TSoftObjectPtr`.\n\n```cpp\nUPROPERTY(EditAnywhere, BlueprintReadWrite)\nTSoftClassPtr\u003CAWeapon> WeaponClassToLoad;\n\nvoid AMyCharacter::Equip() {\n    if (WeaponClassToLoad.IsPending()) {\n        WeaponClassToLoad.LoadSynchronous(); \u002F\u002F Or use StreamableManager for async\n    }\n}\n```\n\n## Debugging\n\n*   **Logging**: Use `UE_LOG` with custom categories.\n    ```cpp\n    DEFINE_LOG_CATEGORY_STATIC(LogMyGame, Log, All);\n    UE_LOG(LogMyGame, Warning, TEXT(\"Health is low: %f\"), CurrentHealth);\n    ```\n*   **Screen Messages**:\n    ```cpp\n    if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT(\"Died!\"));\n    ```\n*   **Visual Logger**: extremely useful for AI debugging. Implement `IVisualLoggerDebugSnapshotInterface`.\n\n## Checklist before PR\n\n- [ ] Does this Actor need to Tick? Can it be a Timer?\n- [ ] Are all `UObject*` members wrapped in `UPROPERTY`?\n- [ ] Are hard references (TSubclassOf) causing load chains? Can they be Soft Ptrs?\n- [ ] Did you clean up verified delegates in `EndPlay`?\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,223,842,"2026-05-16 13:45:33",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"前端开发","frontend","mdi-language-html5","HTML\u002FCSS\u002FJavaScript\u002F框架相关",1,96,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"2a9ca092-3547-4fe8-a938-721ddeb04f58","1.0.0","unreal-engine-cpp-pro.zip",3912,"uploads\u002Fskills\u002Faf036753-cf5c-4e94-893a-27d63bc1ff5c\u002Funreal-engine-cpp-pro.zip","f4c6b67d69081be8c795bb3a18625baa73bae45d8cbf43d844f30f58cbbde636","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":4851},{\"path\":\"examples\u002FExampleActor.cpp\",\"isDirectory\":false,\"size\":1152},{\"path\":\"examples\u002FExampleActor.h\",\"isDirectory\":false,\"size\":1455}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]