Version: 2023.1
public static bool isPlaying ;

描述

在任何类型的已构建播放器中调用时,或者在播放模式的编辑器中调用时,返回 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.IsPlayingExecuteAlways

using UnityEngine;

class Example : MonoBehaviour { void Start() { if (Application.isPlaying) { print("In player or playmode"); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961