Integration

C++ Integration

The main entry point for C++ integration is the DcJsonAssetRuntime module. The most straight forward way to integrate is to add DcJsonAssetRuntime to your game module's Game.Build.cs:

using UnrealBuildTool;
public class DcProjectGame : ModuleRules
{
    public DcProjectGame(ReadOnlyTargetRules Target) : base(Target)
    {
        // ...
        PublicDependencyModuleNames.AddRange(new string[] {
            "Core",
            "CoreUObject",
            "Engine"
            "DcJsonAssetRuntime", // <-- add reference here
        });
    }
}

Then in your game module you can subclass UDcImportedDataAsset or UDcPrimaryImportedDataAsset to start structuring your data:

// DcJsonAssetTests/Private/DcTestImports1.h
UCLASS()
class UDcJsonAssetTestPrimaryDataAsset1 : public UDcPrimaryImportedDataAsset
{
    // ...
    UPROPERTY(EditAnywhere, Category="DcJsonAsset|Tests") FName AlphaName;
    UPROPERTY(EditAnywhere, Category="DcJsonAsset|Tests") bool AlphaBool;
    UPROPERTY(EditAnywhere, Category="DcJsonAsset|Tests") FString AlphaStr;
};

If you're already deriving UDataAsset in your projects and wants to adapt them to be importable, you can implement IDcImportedInterface interface and the editor tooling would be able to detect them automatically. This is actually how UDcImportedDataAsset and UDcPrimaryImportedDataAsset are implemented:

// DcJsonAssetRuntime/Public/DcImportedInterface.h
class DCJSONASSETRUNTIME_API IDcImportedInterface
{
    // ...
#if WITH_EDITORONLY_DATA
    virtual void GetAssetRegistryTags(TArray<UObject::FAssetRegistryTag>& OutTags) const = 0;

    virtual UAssetImportData* GetAssetImportData() const = 0;
    virtual void SetAssetImportData(UAssetImportData* NewAssetImportData) = 0;
#endif // WITH_EDITORONLY_DATA
};

// DcJsonAssetRuntime\Public\DcImportedDataAsset.h
UCLASS()
class DCJSONASSETRUNTIME_API UDcImportedDataAsset : public UDataAsset, public IDcImportedInterface
{
    // ...
#if WITH_EDITORONLY_DATA
public:
    void GetAssetRegistryTags(TArray<FAssetRegistryTag>& OutTags) const override;

    UAssetImportData* GetAssetImportData() const override;
    void SetAssetImportData(UAssetImportData* NewAssetImportData) override;

    /** Importing data and options used for this asset */
    UPROPERTY(VisibleAnywhere, Instanced, Category = ImportSettings)
    class UAssetImportData* AssetImportData;
#endif // WITH_EDITORONLY_DATA
};

Blueprint Integration

We strongly recommend you author DataAsset classes in C++. It's more resilient and easier to debug this way. However Blueprint DataAsset, and Blueprint Enum/Struct etc are well supported and tested.

Create a Blueprint class and use DcPrimaryImportedDataAsset as base class:

Blueprint DcPrimaryImportedDataAsset

The Blueprint Class can be used as a normal DataAsset. Note that the Asset Import Data is derived from the base class, which is needed for reimport and change detection.

Class Fields