UnrealSpecifiers

repository·main·Indexed 21 days ago

https://github.com/fjz13/unrealspecifiers

A technical resource and AI-ready skill set for Unreal Engine 5 specifiers and metadata. It provides detailed explanations for over 100 specifiers and 300 metas to assist developers and AI agents (such as Codex or Claude Code) in writing correct UE C++ reflection code (UCLASS, UPROPERTY, etc.). The repository includes the ue-specifiers Agent Skill, validation wrappers for UE5.8, and a sample project called Hello.uproject for verifying C++ declarations against editor behavior.

Tokens
304.5K
Snippets
717
Records
872
Agent score
76%

What's inside unrealspecifiers

  1. Overview of UE5 Specifiers and Metas

    main
    The UnrealSpecifiers project provides a detailed reference for Unreal Engine 5 (UE5) specifiers and metas. It covers over 100 specifiers and 300 metas, intended to supplement the official Unreal Engine documentation. This resource is useful for developers needing to understand how to control reflection, Blueprint visibility, DLL exports, and property categorization using UCLASS, USTRUCT, UENUM, UFUNCTION, UPARAM, and UPROPERTY macros.
  2. Use the Constraints Index for UE C++ development

    main

    The Constraints Index is a compact guardrail guide for selecting the correct specifier or metadata combinations when writing Unreal Engine C++ code. Use this index to resolve conflicts or select the appropriate option when a declaration involves:

    • Blueprint access/behavior (e.g., BlueprintReadOnly, BlueprintCallable, BlueprintNativeEvent)
    • Details Panel visibility/editing (e.g., EditAnywhere, VisibleAnywhere, EditCondition)
    • Persistence and Serialization (e.g., SaveGame, Transient, Config)
    • Networking/Replication (e.g., Replicated, ReplicatedUsing, Server, Client)
    • Editor UI/UX (e.g., ClampMin, Bitmask, BindWidget, ExposeOnSpawn)

    When choosing a specifier, always aim for the narrowest scope required by your code path to maintain proper encapsulation and prevent unintended access.

  3. Overview of ue-specifiers skill structure

    main

    The ue-specifiers skill is organized to provide high-speed routing for AI agents, moving from high-level constraints to low-level details:

    • SKILL.md: The core instruction set for the agent, guiding it to choose the minimal and correct specifier/meta combinations.
    • references/indexes/common.index.md: Quick entry point for high-frequency specifiers, ranked by usage frequency.
    • references/indexes/constraints.index.md: A critical index for complex scenarios (e.g., Blueprint exposure, Details Panel, Replication, UMG, etc.). It highlights caveats and risks before the agent reads full documentation.
    • references/indexes/ambiguous-symbols.index.md: Handles symbols that have multiple contexts (e.g., Category, Config, DisplayName).
    • references/sources/: Contains the granular, normalized source details for every individual specifier and meta.
  4. Use Blueprintable to allow Blueprint inheritance

    main

    The Blueprintable specifier allows a class to be used as a base class for creating new Blueprints.

    Key Behaviors:

    • Only classes marked as Blueprintable can be chosen as base classes in the Blueprint editor.
    • Inheritance Rule: If a class is NotBlueprintable, it cannot be inherited within Blueprints, and its inherent effects cannot be treated as variables. However, a subclass can become Blueprintable even if its parent was not, provided the metadata is explicitly set.
    • Variable Usage: Whether a class can be used as a variable type depends on the BlueprintType tag of the parent class hierarchy.
    /* Example: A class that can be used as a base for Blueprints */
    UCLASS(Blueprintable)
    class INSIDER_API UMyClass_Blueprintable : public UObject
    {
    	GENERATED_BODY()
    };
    
    /* Example: A class that cannot be used as a base for Blueprints */
    UCLASS(NotBlueprintable)
    class INSIDER_API UMyClass_NotBlueprintable : public UObject
    {
    	GENERATED_BODY()
    };
  5. Use Abstract to prevent class instantiation

    main

    The abstract specifier designates a class as an abstract base class.

    Key Behaviors:

    • Instantiation: Abstract classes cannot be instantiated. They will not appear in the Blueprint 'Construct Object' list, and calling NewObject<T>() in C++ for an abstract class will result in a fatal error (outside of editor-specific loading contexts).
    • Usage: Typically applied to base classes (e.g., UMyBaseClass) that are intended only to provide functionality for derived classes.
    /* This class can be inherited but cannot be instantiated directly */
    UCLASS(Blueprintable, abstract)
    class INSIDER_API UMyClass_Abstract : public UObject
    {
    	GENERATED_BODY()
    };
  6. How RelativeToGameDir works internally

    main

    The RelativeToGameDir metadata triggers a transformation logic during the path picking process:

    1. The system retrieves the absolute path of the selected item.
    2. It identifies the absolute path of the Project directory using FPaths::ProjectDir().
    3. It checks if the selected absolute path starts with the absolute Project directory path.
    4. If it does, it uses AbsolutePickedPath.RightChop(AbsoluteProjectDir.Len()) to strip the project directory prefix, leaving only the relative path.
    5. If the path is outside the project directory, or if the file does not exist (suggesting it might already be a manually entered relative path), the absolute path or the original input is preserved.
  7. Use SparseClassDataTypes for performance optimization

    main

    SparseClassDataTypes is a UCLASS metadata specifier used to refactor and optimize memory usage. It allows you to move repetitive, immutable, or class-default data from an Actor into a common structure (USTRUCT), reducing the per-instance memory footprint.

    Key Details

    • Engine Module: Blueprint
    • Metadata Type: string="StructName" (e.g., SparseClassDataTypes=MySparseClassData)
    • Mechanism: You define a USTRUCT to hold the data and pass its name as a metadata value to the UCLASS macro. The Unreal Header Tool (UHT) then automatically generates accessors for that struct.
    • Common Use Case: Moving properties that are set in Class Defaults and do not change per instance into a shared structure.
    UCLASS(Blueprintable, BlueprintType, SparseClassDataTypes= MySparseClassData)
    class AMyActor : public AActor
    {
        GENERATED_BODY()
    };
  8. Understand the ModuleRelativePath metadata specifier

    main

    ModuleRelativePath is a metadata specifier managed by the Unreal Header Tool (UHT) that records the relative path of a header file within a module.

    Key Characteristics

    • Purpose: It allows the engine editor to locate the exact .h file where a type is defined. This enables features like double-clicking a type in the editor to open its source code in Visual Studio.
    • Scope: Unlike IncludePath (which is only present on UCLASS), ModuleRelativePath is present on various type information, including classes, properties, and functions.
    • Path Structure: The value can include directory prefixes such as Classes/, Public/, Internal/, or Private/.

    Comparison with IncludePath

    FeatureModuleRelativePathIncludePath
    AvailabilityClasses, Properties, and FunctionsOnly UCLASS
    PrefixesIncludes Classes/Public/Internal/Private
    BehaviorUsed for source navigationUsed for includes

    Best Practices

    It is recommended to organize your .h and .cpp files into the following four directories to align with standard engine patterns:

    • Classes/
    • Public/
    • Internal/
    • Private/
  9. How ConversionRoot affects the Convert Actor editor action

    main

    In the Unreal Engine editor, when an Actor is selected, the Details Panel displays a ConvertActor property bar.

    • With ConversionRoot: If you select an Actor that is a subclass of a ConversionRoot class, the ConvertActor function is enabled. This allows you to transform the Actor between itself and any of its subclasses defined under that root.
    • Without ConversionRoot: If a standard Actor (one without a ConversionRoot defined in its hierarchy) is selected, no transformation can occur because the ConvertActor action is disabled.
  10. How ScriptDefaultMake and ScriptDefaultBreak work in Python

    main

    In Unreal Engine's Python scripting, ScriptDefaultMake and ScriptDefaultBreak are metadata tags used with USTRUCT to control how structures are initialized and converted to tuples.

    • ScriptDefaultMake: When this tag is present, the Python initialization (__init__) will call the default script-side make function instead of the C++ function specified by HasNativeMake.
    • ScriptDefaultBreak: When this tag is present, calling .to_tuple() on the Python object will use the default script-side break logic (converting each attribute to a tuple) instead of the C++ function specified by HasNativeBreak.

    If these tags are not present, the engine falls back to the native C++ functions defined via HasNativeMake and HasNativeBreak metadata.

    // Example of how the logic behaves in C++
    // If ScriptDefaultMake is found, the function specified by HasNativeMake is ignored.
    if (!InStruct->HasMetaData(InScriptDefaultMetaDataKey))
    {
        const FString MakeBreakFunctionName = InStruct->GetMetaData(InNativeMetaDataKey);
        // ... logic to find and use the native function ...
    }
  11. How `ExposedAsyncProxy` works with `UCancellableAsyncAction`

    main

    By default, an async node created from a UBlueprintAsyncActionBase subclass does not expose the task object. However, if you create a helper class like UCancellableAsyncAction that provides a Cancel() method and use ExposedAsyncProxy in your implementation, the resulting Blueprint node will feature an extra output pin. This pin provides a reference to the async action instance, enabling the user to call Cancel() on it later in the Blueprint graph.

    // Base class providing cancellation logic
    UCLASS(Abstract, BlueprintType, meta = (ExposedAsyncProxy = AsyncAction), MinimalAPI)
    class UCancellableAsyncAction : public UBlueprintAsyncActionBase
    {
        UFUNCTION(BlueprintCallable, Category = "Async Action")
        ENGINE_API virtual void Cancel();
    };
    
    // Implementation using the proxy
    UCLASS(Blueprintable, BlueprintType, meta = (ExposedAsyncProxy = MyAsyncObject))
    class INSIDER_API UMyFunction_Async : public UCancellableAsyncAction
    {
        GENERATED_BODY()
    };
  12. How AssetBundles work in Unreal Engine

    main

    Asset management in UE5 distinguishes between three types of assets:

    1. PrimaryAsset: Root assets (like levels or character data) that can be manually loaded/released. They often act as the entry point for a tree of references.
    2. SecondaryAsset: Assets like textures, sounds, or materials that are typically referenced by PrimaryAssets. They are usually loaded automatically when the PrimaryAsset is loaded.
    3. AssetBundle: A logical grouping of assets. Instead of loading all secondary assets referenced by a PrimaryAsset, you can group them into bundles (e.g., "UI" vs "Game") and use UAssetManager to load only the specific bundle required for the current context.

    Workflow:

    1. Define AssetBundles metadata on soft properties in a UPrimaryDataAsset.
    2. UAssetManager analyzes this metadata during PreSave or PostLoad and stores it in AssetBundleData.
    3. At runtime, use UAssetManager::ChangeBundleStateForPrimaryAssets (or similar loading logic) to specify which LoadBundles to include.