- I need to configure Unity by setting some environment variables, but I don't know how.
- I need to contact my network administrator to use Unity with a set of environment variables.
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:
nohup "/Applications/Unity Hub.app/Contents/MacOS/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.
After setting environment variables
You will need to restart both your Unity Editor and the Unity Hub after setting environment variables.
This is great!
How can I set up Unity to use environment variables for Linux? I am using Ubuntu 20.04.
This worked for me on mac, thank you so much.
Thanks for your positive feedback. All the best.
@Aurora if you still require assistance with setting this up on Linux, you can follow the instructions in the link below.
If you have any follow up questions. Please feel free to get back to us at firstname.lastname@example.org
All the best.
Please sign in to leave a comment.