Version: 2017.2
public static bool isEditor ;

描述

是否在 Unity Editor 内运行?(只读)

如果从 Unity Editor 运行游戏,则返回 true;如果从任何部署目标运行,则返回 false。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { if (Application.isEditor) print("We are running this from inside of the editor!"); } }