RealDocs

UGameplayStatics::ParseOption

function Engine Blueprint Since 4.0
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticBlueprintPure

Description

Searches a URL-style options string for a key and returns its value as a string. Returns an empty string if the key is not found; use HasOption first when you need to distinguish between a missing key and an empty-value key.

Caveats & Gotchas

  • The search is case-insensitive, but the returned value preserves its original casing. Comparing the result directly with a case-sensitive FString comparison may produce unexpected mismatches.
  • Options is taken by value and mutated internally during parsing; passing a persistent member variable directly is safe because the caller's original string is not modified (the mutation is to the local copy).

Signature

static ENGINE_API FString ParseOption( FString Options, const FString& Key );

Parameters

Name Type Description Default
Options FString The full options string, typically from AGameModeBase::InitGame's Options parameter.
Key const FString& The key to look up in the options string.

Return Type

FString

Example

Read a custom option in GameMode::InitGame C++
void AMyGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
    Super::InitGame(MapName, Options, ErrorMessage);
    FString Difficulty = UGameplayStatics::ParseOption(Options, TEXT("Difficulty"));
    if (!Difficulty.IsEmpty())
    {
        ApplyDifficulty(Difficulty);
    }
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.