# 条件付きコンパイルをテストする

> Code example and steps to test your conditionally compiled code.

以下の例では、条件付きでコンパイルしたコードをテストする方法を示します。また、ターゲットビルドに選択されたプラットフォームに基づいてメッセージを出力します。

## サンプルコード##sample-code

```lang-csharp

using UnityEngine;
using System.Collections;
public class PlatformDefines : MonoBehaviour {
void Start () {

  #if UNITY_EDITOR
    Debug.Log("Unity Editor");
  #endif

  #if UNITY_IOS
    Debug.Log("Unity iOS");
  #endif

  #if UNITY_STANDALONE_OSX
      Debug.Log("Standalone OSX");
  #endif

  #if UNITY_STANDALONE_WIN
    Debug.Log("Standalone Windows");
  #endif

}			 
} 
```

## テストの手順##test-instructions

1. **Build settings** ウィンドウを開きます (メニュー: **File** > **Build Profiles**)。
2. コードをテストするプラットフォームがアクティブなプラットフォームのプロファイルであることを確認します。アクティブでない場合は、使用するプラットフォームを選択し、**Switch Profile** をクリックします。
3. [スクリプト](/engine/6000.0/manual/scripting/get-started/creating-scripts.md)を作成し、[サンプルコード](#Sample)をコピーして貼り付けます。
4. [Game view](/engine/6000.0/manual/unity-editor/using-the-editor/game-view.md) ツールバーで、再生ボタンをクリックして再生モードにします。Unity コンソールで選択したプラットフォームに関連するメッセージを確認して、コードが機能していることを確認します。例えば、iOS を選択すると、コンソールに `Unity Editor` と `Unity iOS` のメッセージが表示されます。

## 追加リソース##additional-resources

* [Unity スクリプトシンボルのリファレンス](/engine/6000.0/manual/scripting/compilation-and-code-reload/script-compilation/conditional-compilation/symbol-reference.md)
* [カスタム製スクリプトシンボル](/engine/6000.0/manual/scripting/compilation-and-code-reload/script-compilation/conditional-compilation/custom-scripting-symbols.md)
