Unity Environments
Environments are logical partitions for Unity Game Services that contain data associated with your project. Examples can include game code using Cloud Code, or game configurations using Remote Config.
- Environments are isolated. This means that if you change data in one environment, data in other environments is not affected.
- You apply Environments at the project level.
- You can think of Environments as namespaces or labels for your data.
- Creating an environment doesn't provision resources; it enables you to tie data to a specific workspace.
Supported Services
The following services currently support Environments:
Unity Game Services will continue to release Environments support for additional services.
Managing environments
To access a project’s Environments from the Unity Dashboard:
- Select Projects from the primary navigation menu.
- Select the project to which you want to apply Environments from the project drop-down menu.
- Select Environments from the secondary navigation menu.
All projects start with a production environment. You can create up to 25 environments. To create a new environment, click Add Environment, give the new environment a name, and click Create.
Switching environments for a service
Once you’ve created your environments, use the navigation menu to select the supported service that you want to configure. The current environment will be displayed in a drop-down menu. Click the drop-down to select the environment you want to target.
Accessing environments within Unity projects
Use the Services Core initialization options to initialize your Unity Gaming Services in the development environment you want the player to experience. If unspecified, Unity Gaming Services will initialize in the default “production” environment.
Note: The Services Core SDK is included as a dependency for each service that supports Environments. For more information, see documentation on Services Core API.
To do this, include the Unity.Services.Core
and Unity.Services.Core.Environments
namespaces, then invoke the UnityServices.InitializeAsync()
method with an options
parameter configured to pass in the environment name. For example:
Initializing Unity Gaming Services with the "dev" environment.
using Unity.Services.Authentication;
using Unity.Services.Core;
using Unity.Services.Core.Environments;
using UnityEngine;
class InitWithEnvironment : MonoBehaviour {
async void Awake()
{
var options = new InitializationOptions();
options.SetEnvironmentName("dev");
await UnityServices.InitializeAsync(options);
await AuthenticationService.Instance.SignInAnonymouslyAsync();
}
}
If no option is specified, the Environment Selector value is used. If no Environment Selector option is present, 'production' is used as the default.
For more information, refer to Environment Selector.
Important: You must include the Unity.Services.Core.Environments
namespace to access the SetEnvironmentName
method.