以 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 测试服;具体如何应用,由游戏决定