

The simplest way to load a commandline file is to use System.IO, which works on many or perhaps most platforms. Please see the video below where I show the integration steps. Call CommandLine.GetBool(key, defaultValue) and friends to query commandline options.Call CommandLine.Init(text) with the text of the commandline file.

Load the commandline file using your favorite API during application/game startup.I prefer Assets/StreamingAssets/CommandLine.txt, but you can use any path you like. Create a text file in your project that is used to provide commandline options.Something like "CommandLine by Peter Schraut" or "Thanks to Peter Schraut" would be very much appreciated. If you find this package useful, please mention my name in your credits screen. In Unity's Package Manager, choose "Add package from git URL" and insert one of the Package URL's you can find below.

string (use quotes to provide strings with spaces)ĬommandLine supports C-like comments in your text file:Īs of Unity 2019.3, Unity supports to add packages from git through the Package Manager window.If the key could not be found in the commandline.ĬommandLine supports the following types: The second argument, in this case false, represents the default value that is returned, The first argument -InfiniteHealth represents the key. The unknown is editor version & editor path (we generally are pretty-constantly upgrading through each minor release), and we don't want to have to re-invent the wheel & track the editor version ourselves / externally.įWIW, the purpose of this is so that we can create an alias / shortcut / bash script to open up a Unity project and, specifically on macOS, because I want to be able to set a custom "icon" for the bash script/alias - goal being that, when I have 5 Unity projects open (each in their own Unity instance), I can have the macOS 'Dock' icon be displaying a project-specific icon for fast visual ID / workflow reasons.CommandLine. same as it does now, just from the CLI.īasically, I have two constants: UNITY_HUB_PATH and PROJECT_DIR. And of course, it can just throw an error or pop a dialog if the editor version required isn't available, etc.

From there, the Hub can open the project with the proper editor version based on the meta-data that it has. My goal: Ability to open a Unity project, in the proper editor version, without the CLI command needing to contain anything other than the path to the Unity Hub (constant) + path-to-project. Would really like to be able to use the Hub via CLI, as well.
