UE4 steam id 生成 uniqueNetid

gameInstance.h

USTRUCT(BlueprintType)
struct FBPUniqueNetId
{
	GENERATED_BODY();
	TSharedPtr < const FUniqueNetId > UniqueNetId;
};


gameInstance.cpp

FBPUniqueNetId  UMyGameInstance::GenerateUniqueID(const FString& Str)
{
	TSharedPtr < const FUniqueNetId > netID;

	if (IOnlineSubsystem* SubSystem = IOnlineSubsystem::Get())
	{
		IOnlineIdentityPtr IdentityInterface = SubSystem->GetIdentityInterface();
		if (IdentityInterface.IsValid())
		{
			netID = IdentityInterface->CreateUniquePlayerId(Str);
		}
	}
	FBPUniqueNetId bpNetId;
	bpNetId.UniqueNetId = netID;
	return bpNetId;


}

xxx.cpp //其他地方碰到CSteamID的时候

	UMyGameInstance* gameInstance = Cast(GetWorld()->GetGameInstance());
			FString steamIdString = FString::FromInt(friendSteamId.ConvertToUint64());
			FBPUniqueNetId bpNetId = gameInstance->GenerateUniqueID(steamIdString);
			OnInvite.Broadcast(bpNetId);

你可能感兴趣的:(unreal,engine,unreal4,unreal)