《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测试服;具体如何使用,由游戏决定
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论