在任何类型的已构建播放器中调用时,或者在播放模式的编辑器中调用时,返回 true(只读)。
In a built Player, this method always returns true.
In the Editor, it returns true if the Editor is in Play mode.
Note: In the Editor for ScriptableObject assets, this property returns false in OnEnable. After reloading the domain, when reloading assemblies, Unity invokes OnEnable on all ScriptableObject instances. This happens before isPlaying is set to true.
另请参阅:Application.IsPlaying、ExecuteAlways。
using UnityEngine;
class Example : MonoBehaviour { void Start() { if (Application.isPlaying) { print("In player or playmode"); } } }