关于游戏开发:UE4游戏开发之-如何获取启动时设置的启动参数

以PS设置启动参数为例:

要在游戏中获取启动参数值,须要晓得启动参数,保留的地位:
须要理解【Engine\Source\Runtime\Core\Public\Misc\CommandLine.h】

/** 
     * Returns an edited version of the executable's command line
     *  with the game name and certain other parameters removed
     * 获取启动参数字符串. 
     */
    static const TCHAR* Get();
    /**
     * Parses a string into tokens, separating switches (beginning with -) from
     * other parameters
     * 解析命令字符串
     *
     * @param    CmdLine        the string to parse
     * @param    Tokens        [out] filled with all parameters found in the string
     * @param    Switches    [out] filled with all switches found in the string
     */
    static void Parse(const TCHAR* CmdLine, TArray<FString>& Tokens, TArray<FString>& Switches);

应用形式

    TArray<FString> Tokens;
    TArray<FString> Switches;
    FCommandLine::Parse(FCommandLine::Get(), Tokens, Switches);

只须要解析Switches的字符串就能够获取,key与Value;在这里key:Dev,Value:PS4测试服;具体如何应用,由游戏决定

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理