Sign In Register

How can we help you today?

Start a new topic
Answered

How do you convert Optional::t_String to FString? (Unreal Engine)

Hello. I am trying to retrieve the display name but I fail horribly...can you help me on this one? Here is my code snippet:


void UGameSparkStatics::AccountDetailsRequest_Response(GameSparks::Core::GS & gs, const GameSparks::Api::Responses::AccountDetailsResponse & resp)

{

 if (initialized && !resp.GetHasErrors())

  displayname = resp.GetDisplayName();

}


And here is the declaration of display name:


 static FString displayname;


I have also tried gsstl::string as the documentation suggest but with no luck. (I can't convert Optional::t_String to std:string)


Thank you very much!


Best Answer

In their Plugin, they do it like this:

if(wrappedData.ContainsKey("displayName")){

  HasDisplayName = true;

   DisplayName = FString(UTF8_TO_TCHAR(wrappedData.GetString("displayName").GetValue().c_str()));

  }


where "wrappedData" is "const GameSparks::Core::GSData& wrappedData".


Maybe that helps you (:

  


Answer

In their Plugin, they do it like this:

if(wrappedData.ContainsKey("displayName")){

  HasDisplayName = true;

   DisplayName = FString(UTF8_TO_TCHAR(wrappedData.GetString("displayName").GetValue().c_str()));

  }


where "wrappedData" is "const GameSparks::Core::GSData& wrappedData".


Maybe that helps you (:

  


1 person likes this

This works. Thank you very much! :)

Hello! I'm using successfully this code:

FString displayName = response.GetDisplayName().GetValue().c_str();

 A greeting!

Login to post a comment