Version: 2022.2
public static bool isEditor ;

描述

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

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

using UnityEngine;

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