I need to start Unity with an environment variable(s) set, how can I do that?

  • I have to use my network administrator to start Unity with environment variable(s) set, but I do not know how.
  • I need to set some configuration for Unity via environment variable(s), but I do not know how.
You are trying to pass some configuration to Unity via environment variables. For example, you want Unity to use the proxy server configured by the HTTP_PROXY environment variable.
Follow the instructions below to set environment variables for your operating system.
Make sure to replace 'MY_VARIABLE_NAME' with the name of your environment variable (e.g. HTTP_PROXY) and replace 'my_variable_value' with the value you’d like to set.
Set environment variables on Windows
Via Windows settings:
1) Open Start menu > search “Edit environment variables for your account”
2) Under “User variables”, click “New…” > Fill in the “Variable name” and “Variable value” fields with the desired values.
Via command line:
1) Open Start menu > Type “cmd” > open Command Prompt
2) Type the following command and press enter:
setx MY_VARIABLE_NAME my_variable_value
Set environment variables on Mac
On Mac, applications such as Unity do not inherit environment variables from your settings like they do on Windows.
On Mac, the best way to pass environment variables to Unity is via a wrapper script. The wrapper script will first set the environment variables and then launch Unity Hub which will inherit the values you set.
1) Open a Terminal window and enter the following script after replacing 'MY_VARIABLE_NAME' and 'my_variable_value' with the desired values and adjusting the Hub install path as needed:
echo '#!/bin/bash
export MY_VARIABLE_NAME=my_variable_value
export MY_OTHER_VARIABLE_NAME=my_other_variable_value
nohup "/Applications/Unity Hub" &>/dev/null &' > launchUnityHub.command
chmod +x launchUnityHub.command
2) This creates the 'launchUnityHub.command' file, which you can move to a convenient location (e.g. the Desktop).
3) Double-click the file to launch the Hub with the environment variables set, or invoke it from the terminal for the same effect. These environment variables will be passed on to any Unity Editor process launched from the Hub.
More Information:
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.