【问题标题】:What is a correct way to obtain FOnlineSubsystemSteam instance in c++ code在 C++ 代码中获取 FOnlineSubsystemSteam 实例的正确方法是什么
【发布时间】:2020-05-18 13:08:50
【问题描述】:

我正在尝试通过以下方式在我的虚幻引擎 4 项目中获取 Steam 应用 ID 和 Steam 用户 ID:

if (SteamAPI_Init())
{
    IOnlineSubsystem* ossBase = IOnlineSubsystem::Get();
    FOnlineSubsystemSteam* oss = Cast<FOnlineSubsystemSteam*>(ossBase);

    if (!oss) {
        printText(TEXT("Steam Subsystem is down!"), FColor::Red.WithAlpha(255));
        return;
    }

    auto SteamID = FString(std::to_string(SteamUser()->GetSteamID().ConvertToUint64()).c_str());
    auto AppID = FString(std::to_string(oss->GetSteamAppId()).c_str());

但无法将 IOnlineSubsystem 转换为 FOnlineSubsystemSteam。那么获取 FOnlineSubsystemSteam 实例的正确方法是什么?

【问题讨论】:

    标签: unreal-engine4 steam steamworks-api


    【解决方案1】:

    解决方法是使用static_cast:

    FOnlineSubsystemSteam* oss = static_cast<FOnlineSubsystemSteam*>(ossBase);
    

    这个有效。使用 UE4 Cast 似乎很明显,但在这种情况下它不起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-03
      • 2022-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-13
      • 2020-05-24
      • 2021-05-24
      相关资源
      最近更新 更多