The type or namespace name "UnrealBuildTool" could not be found

.build.cs file

using UnrealBuildTool;

public class LicenseManager : ModuleRules
{
public LicenseManager(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

    PublicIncludePaths.AddRange(
        new string[] {
            // ... add public include paths required here ...
        }
    );

    PrivateIncludePaths.AddRange(
        new string[] {
            // ... add other private include paths required here ...
        }
    );

    PublicDependencyModuleNames.AddRange(
        new string[]
        {
            "Core",
            "HTTP", // Ensure this is added for HTTP requests
            "Json", // JSON handling
            "JsonUtilities" // JSON utilities
        }
    );

    PrivateDependencyModuleNames.AddRange(
        new string[]
        {
            "CoreUObject",
            "Engine",
            "Slate",
            "SlateCore",
        }
    );
}

}

.h file

#pragma once

include “CoreMinimal.h”
include “Kismet/BlueprintFunctionLibrary.h”
include “LicenseManager.generated.h”

UCLASS()
class LICENSEMANAGER_API ULicenseManager : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

public:
UFUNCTION(BlueprintCallable, Category = “License”)
static FString GenerateLicenseKey();

UFUNCTION(BlueprintCallable, Category = "License")
static bool ValidateLicenseKey(const FString& Key, bool bValidateOnline);

UFUNCTION(BlueprintCallable, Category = "License")
static bool ValidateKeyOffline(const FString& Key);

UFUNCTION(BlueprintCallable, Category = "License")
static bool ValidateKeyOnline(const FString& Key);

};

.cpp file

include “LicenseManager.h”
include “Misc/Guid.h”
include “Misc/SecureHash.h”
include “HttpModule.h”
include “Interfaces/IHttpRequest.h”
include “Interfaces/IHttpResponse.h”

FString ULicenseManager::GenerateLicenseKey()
{
FGuid NewGuid = FGuid::NewGuid();
return FString::Printf(TEXT(“PIXEL-%s”), *NewGuid.ToString(EGuidFormats::Digits));
}

bool ULicenseManager::ValidateLicenseKey(const FString& Key, bool bValidateOnline)
{
if (bValidateOnline)
{
return ValidateKeyOnline(Key);
}
else
{
return ValidateKeyOffline(Key);
}
}

bool ULicenseManager::ValidateKeyOffline(const FString& Key)
{
return Key.StartsWith(TEXT(“PIXEL-”));
}

bool ULicenseManager::ValidateKeyOnline(const FString& Key)
{
// Simplified online validation example
// Replace with your actual server-side validation logic
return false;
}

1 Like