https://github.com/candycoded/env
Use .env files in your Unity projects.
https://github.com/candycoded/env
Last synced: about 1 month ago
JSON representation
Use .env files in your Unity projects.
- Host: GitHub
- URL: https://github.com/candycoded/env
- Owner: CandyCoded
- License: mit
- Created: 2021-03-08T23:24:41.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-27T04:36:07.000Z (3 months ago)
- Last Synced: 2025-03-31T08:07:51.756Z (about 2 months ago)
- Language: C#
- Homepage:
- Size: 43.9 KB
- Stars: 52
- Watchers: 1
- Forks: 12
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# env
> Use `.env` files in your Unity projects.
[](https://www.npmjs.com/package/xyz.candycoded.env)
### Unity Package Manager
#### Git
```json
{
"dependencies": {
"xyz.candycoded.env": "https://github.com/CandyCoded/env.git#v1.1.5",
...
}
}
```#### Scoped UPM Registry
```json
{
"dependencies": {
"xyz.candycoded.env": "1.1.5",
...
},
"scopedRegistries": [
{
"name": "candycoded",
"url": "https://registry.npmjs.com",
"scopes": ["xyz.candycoded"]
}
]
}
```## Usage
Create a `.env` file at the root of your project, outside of the `Assets/` folder, and paste the following content:
```
DEBUG=true
```Or use the Editor panel found by navigating to **Window** > **CandyCoded** > **Environment File Editor**.
![]()
> Note: Don't forget to add `.env` to your `.gitignore` file before committing any changes!
Now you can reference the variables and their values with the key specified in the `.env` file. Supported value types
are `string`, `bool`, `double`, `float`, and `int`.```csharp
if (env.TryParseEnvironmentVariable("DEBUG", out bool isDebug))
{
Debug.Log($"Debug Mode is: {(isDebug ? "ON" : "OFF")}");
}
```