# Unity Environments

> Use logical partitions to organize your service data for testing, staging, and production workflows.

環境は、プロジェクトに関連付けられたデータを含む Unity Game Services の論理パーティションです。例えば、[Cloud Code](/cloud-code.md) を使用したゲームコードや [Remote Config](/remote-config.md) を使用したゲーム設定などがあります。

* 環境は分離されています。つまり、1 つの環境でデータを変更しても、他の環境のデータには影響しません。
* 環境はプロジェクトレベルで適用します。
* 環境は、データの名前空間やラベルのようなものです。
* 環境を作成してもリソースのプロビジョニングは行われませんが、環境を使用してデータを特定のワークスペースに関連付けることができます。

## サポートされているサービス##supported-services

環境は現在、以下のサービスでサポートされています。

* [分析](/analytics.md)
* [Cloud Code](/cloud-code.md)
* [Cloud Content Delivery](/ccd.md)
* [Cloud Save](/cloud-save.md)
* [Economy](/economy.md)
* [Lobby](/lobby.md)
* [Relay](/relay.md)
* [Remote Config](/remote-config.md)

Unity Gaming Services では、他サービスの環境サポートも継続してリリースしていく予定です。

## 環境の管理##managing-environments

[Unity Dashboard](https://cloud.unity.com/) からプロジェクトの環境にアクセスするには、次の手順に従います。

1. プライマリナビゲーションメニューから **Projects** (プロジェクト) を選択します。
2. 環境を適用するプロジェクトを選択します。
3. **Environments** (環境) タブを選択します。

プロジェクトはすべて、本番環境で開始されます。環境は最大で 25 個作成できます。新しい環境を作成するには、**Add Environment** (環境を追加) をクリックし、新しい環境に名前を付けて、**Add** (追加) を選択します。

## サービスの環境の切り替え##switching-environments-for-a-service

Unity Dashboard でサービスの環境を切り替えるには、次の手順に従います。

1. プライマリナビゲーションメニューから **Projects** (プロジェクト) を選択します。
2. 環境を変更するプロジェクトを選択します。
3. **Environments** (環境) タブを選択します。
4. 使用する環境を選択します。

## Unity プロジェクト内での環境へのアクセス##accessing-environments-within-unity-projects

Services Core の初期化オプションを使用して、プレイヤーに体験させる開発環境で Unity Gaming Services を初期化します。指定しない場合、Unity Gaming Services はデフォルトの “production” 環境で初期化されます。

> **Note:**
>
> **ノート**: 環境をサポートする各サービスの依存関係として、Services Core SDK が含まれています。詳細については、[Services Core API](./services-core-api.md) に関するドキュメントを参照してください。

これを行うには、`Unity.Services.Core` および `Unity.Services.Core.Environments` 名前空間を追加し、環境名を渡すよう設定した `options` パラメーターを指定して `UnityServices.InitializeAsync()` メソッドを呼び出します。例を次に示します。

*“dev” 環境での Unity Gaming Services の初期化。*

```plaintext
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();
   }
}
```

オプションを指定しない場合、Environment Selector (環境セレクター) の値が使用されます。環境セレクターオプションが存在しない場合、'production' がデフォルトとして使用されます。

詳細については、[Environment Selector](./environments-api.md#environment-selector) を参照してください。

> **Warning:**
>
> **重要**: `SetEnvironmentName` メソッドにアクセスするには、`Unity.Services.Core.Environments` 名前空間を追加する必要があります。
