简体   繁体   English

如何在Unity上的Linux中设置默认命令行参数

[英]How set default command line parameters in linux build on Unity

I have some problems with local on Linux. 我在Linux上的本地存在一些问题。

Problem fixes when I run build with "LANG=C" problem fixes. 使用“ LANG = C”问题修复程序运行构建时的问题修复程序。

How can I set this parameter as a default parameter in Linux build? 如何在Linux构建中将此参数设置为默认参数?

I can think of two ways to do this off of the top of my head. 我可以想到两种方法来解决这个问题。

Batch Launching 批量启动

The first would be to simply create a shell script (either a batch file on Windows or bash on Linux, or whatever the equivalent is for your target platform) that launches the default program with the provided arguments; 第一种方法是简单地创建一个shell脚本(在Windows上是批处理文件,在Linux上是bash,或与目标平台等效的任何文件),以使用提供的参数启动默认程序。 then treat the launcher script like the default program so no one gets confused. 然后将启动程序脚本视为默认程序,这样就不会让人感到困惑。

Some DDS services, like Steam, allow for custom launch arguments, so you might want to append the call with $@ to add all arguments to the end. 一些DDS服务(例如Steam)允许自定义启动参数,因此您可能希望在调用后附加$@以将所有参数添加到末尾。

So your batch launcher would just contain something like 所以您的批处理启动器将只包含类似

LANG=C ./my_game_name.x86 $@

It's worth noting that I've heard of this problem before, generally in non-English locales, and LC_ALL=C is also considered important. 值得注意的是,我以前在非英语语言环境中听说过此问题,并且LC_ALL = C也被认为很重要。 I can't advise on why, though. 不过,我不知道为什么。 That would make it more like: 那将使其更像:

LC_ALL=C LANG=C ./my_game_name.x86 $@

Custom Launcher 自定义启动器

The other option is much the same, but via an executable file, likely written in C# (since you're already using Unity), that runs the program with the default option. 另一个选项几乎相同,但是通过可执行文件(可能是用C#编写的(因为您已经在使用Unity)),该文件使用默认选项运行程序。 As an reasonably-old-school Linux user I find it against my liking, but there's a decent example at https://loune.net/2017/06/running-shell-bash-commands-in-net-core/ . 作为一个学习程度较高的Linux用户,我发现我不喜欢它,但是在https://loune.net/2017/06/running-shell-bash-commands-in-net-core/中有一个不错的示例。 You would likely need to compile it for Linux through Visual Studio. 您可能需要通过Visual Studio为Linux编译它。

The same can be said for more platform-agnostic languages like Python or Ruby. 对于与平台无关的更多语言,例如Python或Ruby,也可以这样说。 I prefer batch launching because it cuts-to-the-chase. 我更喜欢批量启动,因为它很简单。

Just make sure your launcher is marked as executable with chmod u+x ./launcher_name 只需确保使用chmod u+x ./launcher_name将启动器标记为可执行文件chmod u+x ./launcher_name

It is likely that Unity has some way of setting this as a default, but I've found no reference to it yet and I know games have been published in the past with this exact method. Unity可能有某种方式可以将其设置为默认值,但我尚未找到它的引用,而且我知道过去已经使用这种确切的方法发布了游戏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM